diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index e3f547f..6333305 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -71,6 +71,6 @@ jobs:
- name: Coverage Check
run: |
npm install
- node scripts/coverage/index.mjs
+ npm run test:coverage
diff --git a/docs/overview.mdx b/docs/overview.mdx
index 851ce3b..cd8db5c 100644
--- a/docs/overview.mdx
+++ b/docs/overview.mdx
@@ -14,8 +14,8 @@ The playground is an interactive and graphical IDE that includes a reference for
You can test out the Fuel GraphQL API playground here:
-https://beta-5.fuel.network/playground
+https://testnet.fuel.network/v1/playground
## RPC Endpoint
-https://beta-5.fuel.network/graphql
+https://testnet.fuel.network/v1/graphql
diff --git a/docs/querying-from-a-dapp.mdx b/docs/querying-from-a-dapp.mdx
index a69cc6b..b774db4 100644
--- a/docs/querying-from-a-dapp.mdx
+++ b/docs/querying-from-a-dapp.mdx
@@ -11,7 +11,7 @@ This section covers just a few options available to get you started.
```javascript
export async function getHealth() {
- let response = await fetch('https://beta-5.fuel.network/graphql', {
+ let response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -36,7 +36,7 @@ npm install @apollo/client graphql
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
@@ -66,7 +66,7 @@ npm install urql graphql
import { Client, cacheExchange, fetchExchange } from 'urql';
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
diff --git a/docs/reference/enums.mdx b/docs/reference/enums.mdx
index 0d5ff99..8f44a83 100644
--- a/docs/reference/enums.mdx
+++ b/docs/reference/enums.mdx
@@ -5,6 +5,34 @@ category: Reference
# Enums
+## `ConsensusParametersVersion`
+
+The version of the consensus parameters.
+
+`V1`:
+Version 1.
+
+## `ContractParametersVersion`
+
+The version of the contract-specific consensus parameters.
+
+`V1`:
+Version 1.
+
+## `FeeParametersVersion`
+
+The version of the fee-specific consensus parameters.
+
+`V1`:
+Version 1.
+
+## `GasCostsVersion`
+
+The version of the gas-specific consensus parameters.
+
+`V1`:
+Version 1.
+
## `MessageState`
The state of a message, either `UNSPENT`, `SPENT`, or `NOT_FOUND`.
@@ -61,6 +89,13 @@ The receipt was generated from a mint.
`BURN`:
The receipt was generated from a burn.
+## `PredicateParametersVersion`
+
+The version of the predicate-specific consensus parameters.
+
+`V1`:
+Version 1.
+
## `ReturnType`
The type of return response for a transaction
@@ -83,3 +118,17 @@ All breakpoints have been processed, and the program has terminated.
`BREAKPOINT`:
The program stopped on a breakpoint.
+
+## `ScriptParametersVersion`
+
+The version of the script-specific consensus parameters.
+
+`V1`:
+Version 1.
+
+## `TxParametersVersion`
+
+The version of the transaction-specific consensus parameters.
+
+`V1`:
+Version 1.
diff --git a/docs/reference/mutations.mdx b/docs/reference/mutations.mdx
index 90a2145..7376e35 100644
--- a/docs/reference/mutations.mdx
+++ b/docs/reference/mutations.mdx
@@ -108,15 +108,15 @@ The session ID.
## `dryRun`
-Spin up a new temporary node from the current state and emulate a given transaction.
+Spin up a new temporary node from the current state and emulate a given transaction or set of transactions.
Returns a [`[Receipt!]!`](/docs/reference/objects/#receipt) for the emulated transaction.
You can optionally use UTXO validation.
**args:**
-`tx`: [`HexString!`](/docs/reference/scalars/#hexstring)
+`txs`: [`[HexString!]!`](/docs/reference/scalars/#hexstring)
-The transaction hex string.
+An array of transaction hex strings.
`utxoValidation`: `Boolean`
Whether or not to use UTXO validation.
diff --git a/docs/reference/objects.mdx b/docs/reference/objects.mdx
index b782cba..5d5bc32 100644
--- a/docs/reference/objects.mdx
+++ b/docs/reference/objects.mdx
@@ -43,6 +43,10 @@ Information about a block in the network.
A unique identifier for the block.
+`height`: [`U32!`](/docs/reference/scalars/#u32)
+
+The height of the block.
+
`header`: [`Header!`](#header)
Metadata about a block.
@@ -78,7 +82,7 @@ Information about the base chain. At a very high level `chainInfo` helps you und
`name`: `String!`
-The human-readable string name of the chain. i.e. beta-5
+The human-readable string name of the chain. i.e. `Upgradable Testnet`.
`latestBlock`: [`Block!`](#block)
@@ -136,10 +140,6 @@ The amount of coins.
The asset id of the coin.
-`maturity`: [`U32!`](/docs/reference/scalars/#u32)
-
-The UTXO being spent must have been created at least this many blocks ago.
-
`blockCreated`: [`U32!`](/docs/reference/scalars/#u32)
The block when the coins were created.
@@ -186,30 +186,38 @@ The consensus parameters used for validating blocks.
**fields:**
+`version`: [`ConsensusParametersVersion!`](/docs/reference/unions/#consensusparametersversion)
+
+The version of the consensus parameters.
+
`txParams`: [`TxParameters!`](#txparameters)
-The allowed parameters of transactions
+The allowed parameters of transactions.
`predicateParams`: [`PredicateParameters!`](#predicateparameters)
-The allowed parameters of predicates
+The allowed parameters of predicates.
`scriptParams`: [`ScriptParameters!`](#scriptparameters)
-The allowed parameters of scripts
+The allowed parameters of scripts.
`contractParams`: [`ContractParameters!`](#contractparameters)
-The allowed parameters of contracts
+The allowed parameters of contracts.
`feeParams`: [`FeeParameters!`](#feeparameters)
-The allowed parameters of fees
+The allowed parameters of fees.
`baseAssetId`: [`AssetId!`](/docs/reference/scalars/#assetid)
The asset id of the "base" asset used for gas fees.
+`blockGasLimit`: [`U64!`](/docs/reference/scalars/#u64)
+
+The maximum amount of gas spend allowed in a block.
+
`chainId`: [`U64!`](/docs/reference/scalars/#u64)
A unique identifier for the chain.
@@ -218,6 +226,25 @@ A unique identifier for the chain.
The gas cost of each opcode.
+`privilegedAddress`: [`Address!`](/docs/reference/scalars/#address)
+
+The address used to authorize network upgrades via the `Upgrade` transaction.
+
+## `ConsensusParametersPurpose`
+
+Details about the consensus parameters that are being upgraded.
+
+**fields:**
+
+`witnessIndex`: [`U16!`](/docs/reference/scalars/#u16)
+
+The index of the witness in the `witnesses` field that contains the serialized consensus parameters. For an upgrade to consensus parameters, the upgraded parameters are stored as a witness in the transaction.
+
+`checksum`: [`Bytes32!`](/docs/reference/scalars/#bytes32)
+
+The hash of the serialized consensus parameters.
+Since the serialized consensus parameters live inside the transaction witnesses (which is malleable data), any party can override them. The `checksum` is used to verify that the data was not modified or tampered with.
+
## `Contract`
An object representing a deployed contract.
@@ -298,17 +325,95 @@ The state root of contract after transaction execution.
## `ContractParameters`
-An object containing information about a contract.
+Contract-specific consensus parameters.
**fields:**
+`version`: [`ContractParametersVersion!`](/docs/reference/unions/#contractparametersversion)
+
+The version of the contract-specific consensus parameters.
+
`contractMaxSize`: [`U64!`](/docs/reference/scalars/#u64)
-Maximum size of a contract in bytes
+Maximum size of a contract in bytes.
`maxStorageSlots`: [`U64!`](/docs/reference/scalars/#u64)
-Maximum number of storage slots
+Maximum number of storage slots.
+
+## `DryRunTransactionExecutionStatus`
+
+Details about the status of a transaction dry run.
+
+**fields:**
+
+`id`: [`TransactionId!`](/docs/reference/scalars/#transactionid)
+
+The transaction ID.
+
+`status`: [`DryRunTransactionStatus!`](/docs/reference/unions/#dryruntransactionstatus)
+
+The status of the transaction dry run.
+
+`receipts`: [`[Receipt!]!`](#receipt)
+
+The receipts for the transaction dry run.
+
+## `DryRunFailureStatus`
+
+The status details of a failed transaction dry run.
+
+**fields:**
+
+`programState`: [`ProgramState`](#programstate)
+
+The state of the program execution.
+
+`reason`: `String!`
+
+The reason why the transaction dry run failed.
+
+`receipts`: [`[Receipt!]!`](#receipt)
+
+The transaction dry run receipts.
+
+`totalGas`: [`U64!`](/docs/reference/scalars/#u64)
+
+The total amount of gas used.
+
+`totalFee`: [`U64!`](/docs/reference/scalars/#u64)
+
+The total fee for the transaction.
+
+## `DryRunSuccessStatus`
+
+The status details of a successful transaction dry run.
+
+**fields:**
+
+`programState`: [`ProgramState`](#programstate)
+
+The state of the program execution.
+
+`receipts`: [`[Receipt!]!`](#receipt)
+
+The transaction dry run receipts.
+
+`totalGas`: [`U64!`](/docs/reference/scalars/#u64)
+
+The total amount of gas used.
+
+`totalFee`: [`U64!`](/docs/reference/scalars/#u64)
+
+The total fee for the transaction.
+
+## `EstimateGasPrice`
+
+The estimated gas price for a transaction.
+
+**fields:**
+
+`gasPrice`: [`U64!`](/docs/reference/scalars/#u64)
## `ExcludeInput`
@@ -354,19 +459,31 @@ The state of the program execution.
The receipts for the transaction.
+`totalGas`: [`U64!`](/docs/reference/scalars/#u64)
+
+The total amount of gas used.
+
+`totalFee`: [`U64!`](/docs/reference/scalars/#u64)
+
+The total fee for the transaction.
+
## `FeeParameters`
The consensus parameters for fees.
**fields:**
+`version`: [`FeeParametersVersion!`](/docs/reference/unions/#feeparametersversion)
+
+The version of the consensus parameters.
+
`gasPriceFactor`: [`U64!`](/docs/reference/scalars/#u64)
-The dynamic adjustment of gas costs
+The dynamic adjustment of gas costs.
`gasPerByte`: [`U64!`](/docs/reference/scalars/#u64)
-The gas cost per byte
+The gas cost per byte.
## `GasCosts`
@@ -374,6 +491,10 @@ The breakdown of the gas costs of each opcode.
**fields:**
+`version`: [`GasCostsVersion!`](/docs/reference/unions/#gascostsversion)
+
+The version of the gas-specific consensus parameters.
+
`add`: [`U64!`](/docs/reference/scalars/#u64)
The gas cost of using the `$add` ALU opcode.
@@ -422,10 +543,6 @@ The gas cost of using the `$cfei` memory opcode.
The gas cost of using the `$cfsi` memory opcode.
-`croo`: [`U64!`](/docs/reference/scalars/#u64)
-
-The gas cost of using the `$croo` contract opcode.
-
`div`: [`U64!`](/docs/reference/scalars/#u64)
The gas cost of using the `$div` ALU opcode.
@@ -738,6 +855,10 @@ The `dependent` gas cost of using the `$call` contract opcode.
The `dependent` gas cost of using the `$ccp` contract opcode.
+`croo`: [`DependentCost!`](/docs/reference/unions/#dependentcost)
+
+The `dependent` gas cost of using the `$croo` contract opcode.
+
`csiz`: [`DependentCost!`](/docs/reference/unions/#dependentcost)
The `dependent` gas cost of using the `$csiz` contract opcode.
@@ -836,6 +957,10 @@ The binary Merkle tree root of state, balances, and the contracts code hash of e
The binary merkle tree root of all genesis messages.
+`transactionsRoot`: [`Bytes32!`](/docs/reference/scalars/#bytes32)
+
+The binary Merkle tree root of all previous transactions.
+
## `HeavyOperation`
The operation dependent on the size of its inputs, and the time required per unit of input exceeding that of a single no-op operation
@@ -864,6 +989,14 @@ The current block id.
The block height for the data availability layer up to which (inclusive) input messages are processed.
+`consensusParametersVersion`: [`U32!`](/docs/reference/scalars/#u32)
+
+The version of the consensus parameters.
+
+`stateTransitionBytecodeVersion`: [`U32!`](/docs/reference/scalars/#u32)
+
+The version of the state transition bytecode.
+
`transactionsCount`: [`U64!`](/docs/reference/scalars/#u64)
The number of transactions in the block.
@@ -876,9 +1009,13 @@ The number of receipt messages in the block.
The merkle root of the transactions in the block.
-`messageReceiptRoot`: [`Bytes32!`](/docs/reference/scalars/#bytes32)
+`messageOutboxRoot`: [`Bytes32!`](/docs/reference/scalars/#bytes32)
+
+The Merkle root of the outgoing messages back to the data availability (DA) layer from Fuel, where the inputs are the IDs (`MessageId`) of the messages. The IDs are produced by executing transactions and collecting IDs from the receipts of the `Message` outputs.
-The merkle root of the receipt messages in the block.
+`eventInboxRoot`: [`Bytes32!`](/docs/reference/scalars/#bytes32)
+
+The Merkle root of the incoming events from the data availability (DA) layer to Fuel, where the tree inputs are the hashes of these events.
`height`: [`U32!`](/docs/reference/scalars/#u32)
@@ -926,10 +1063,6 @@ A pointer to the transaction whose output is being spent.
The index of the witness that authorizes spending the coin.
-`maturity`: [`U32!`](/docs/reference/scalars/#u32)
-
-The UTXO being spent must have been created at least this many blocks ago.
-
`predicateGasUsed`: [`U64!`](/docs/reference/scalars/#u64)
The amount of gas used in the predicate transaction.
@@ -964,9 +1097,9 @@ The state root of contract before transaction execution.
A pointer to the TX whose output is being spent.
-`contract`: [`Contract!`](#contract)
+`contractId`: [`ContractId!`](/docs/reference/scalars/#contractid)
-The input contract.
+The input contract's ID.
## `InputMessage`
@@ -1010,6 +1143,20 @@ The predicate bytecode.
The predicate input parameters.
+## `LatestGasPrice`
+
+Information about the latest price of gas.
+
+**fields:**
+
+`gasPrice`: [`U64!`](/docs/reference/scalars/#u64)
+
+The gas price for the latest block produced.
+
+`blockHeight`: [`U32!`](/docs/reference/scalars/#u32)
+
+The block height for the latest block produced.
+
## `LightOperation`
The operation dependent on the size of its inputs, and the time required per unit of input less that of a single no-op operation
@@ -1164,10 +1311,6 @@ Whether or not the node is using UTXO validation.
Whether or not logging of backtraces from VM errors is enabled.
-`minGasPrice`: [`U64!`](/docs/reference/scalars/#u64)
-
-The minimum gas price for the node.
-
`maxTx`: [`U64!`](/docs/reference/scalars/#u64)
The maximum number of transactions.
@@ -1258,9 +1401,9 @@ Information about the policies of a transaction.
**fields:**
-`gasPrice`: [`U64`](/docs/reference/scalars/#u64)
+`tip`: [`U64`](/docs/reference/scalars/#u64)
-The price for each unit of gas consumed during the transaction execution.
+The user-defined `tip` is a new transaction policy that replaced the `GasPrice` transaction policy. `Tip` allows the user to specify how much they want to pay to the block producer to incentivize them to include the user's transaction in the block.
`witnessLimit`: [`U64`](/docs/reference/scalars/#u64)
@@ -1276,10 +1419,14 @@ The maximum fee allowed for the transaction to consume.
## `PredicateParameters`
-The consensus parameters for a predicate.
+The consensus parameters for predicates.
**fields:**
+`version`: [`PredicateParametersVersion!`](/docs/reference/unions/#predicateparametersversion)
+
+The version of the consensus parameters.
+
`maxPredicateLength`: [`U64!`](/docs/reference/scalars/#u64)
The maximum length of a predicate.
@@ -1302,9 +1449,9 @@ An object representing all possible types of receipts.
**fields:**
-`contract`: [`Contract`](#contract)
+`id`: [`ContractId!`](/docs/reference/scalars/#contractid)
-The contract that produced the receipt.
+The ID of the contract that produced the receipt.
`pc`: [`U64`](/docs/reference/scalars/#u64)
@@ -1414,6 +1561,20 @@ The contract id.
The sub id.
+## `RelayedTransactionFailed`
+
+Details about why a relayed transaction from an L1 failed.
+
+**fields:**
+
+`blockHeight`: `U32!`
+
+The block height at the time the relayed transaction failed.
+
+`failure`: `String!`
+
+The reason why the transaction failed.
+
## `RunResult`
The result of a transaction execution.
@@ -1438,6 +1599,10 @@ The consensus parameters for a script.
**fields:**
+`version`: [`ScriptParametersVersion!`](/docs/reference/unions/#scriptparametersversion)
+
+The version of the consensus parameters.
+
`maxScriptLength`: [`U64!`](/docs/reference/scalars/#u64)
The maximum length of a script.
@@ -1474,6 +1639,16 @@ The status for a transaction that was squeezed out of the transaction pool.
The reason why the transaction was squeezed out.
+## `StateTransitionPurpose`
+
+Details about a state transition upgrade.
+
+**fields:**
+
+`root`: [`Bytes32!`](/docs/reference/scalars/#bytes32)
+
+The merkle root of the new state.
+
## `SuccessStatus`
The status of a successful transaction.
@@ -1500,6 +1675,14 @@ The state of the program execution.
The transaction receipts.
+`totalGas`: [`U64!`](/docs/reference/scalars/#u64)
+
+The total amount of gas used.
+
+`totalFee`: [`U64!`](/docs/reference/scalars/#u64)
+
+The total fee for the transaction.
+
## `SubmittedStatus`
The status for a submitted transaction.
@@ -1536,10 +1719,6 @@ A contract used for the transaction input.
The policies for the transaction.
-`gasPrice`: [`U64`](/docs/reference/scalars/#u64)
-
-The gas price for the transaction.
-
`scriptGasLimit`: [`U64`](/docs/reference/scalars/#u64)
The gas limit for the transaction.
@@ -1556,6 +1735,10 @@ The amount minted in the transaction.
The asset ID for coins minted in the transaction.
+`mintGasPrice`: [`U64!`](/docs/reference/scalars/#u64)
+
+The gas price at the time of minting the block.
+
`txPointer`: [`TxPointer`](/docs/reference/scalars/#txpointer)
The location of the transaction in the block.
@@ -1572,6 +1755,14 @@ Whether or not the transaction is creating a new contract.
Whether or not the transaction is minting new coins.
+`isUpgrade`: `Boolean!`
+
+Whether or not the transaction is upgrading the network.
+
+`isUpload`: `Boolean!`
+
+Whether or not the transaction is uploading state transition data to prepare for upgrading the network.
+
`inputs`: [`[Input!]`](/docs/reference/unions/#input)
An array of inputs for the transaction.
@@ -1596,10 +1787,6 @@ The root of the receipts.
The status of the transaction.
-`receipts`: [`[Receipt!]`](#receipt)
-
-An array of the receipts produced by the transaction.
-
`script`: [`HexString`](/docs/reference/scalars/#hexstring)
The script to execute.
@@ -1612,10 +1799,6 @@ The script input parameters.
The witness index of contract bytecode.
-`bytecodeLength`: [`U64`](/docs/reference/scalars/#u64)
-
-The length of the transaction bytecode.
-
`salt`: [`Salt`](/docs/reference/scalars/#salt)
The salt value for the transaction.
@@ -1624,6 +1807,26 @@ The salt value for the transaction.
An array of storage slot.
+`bytecodeRoot`: [`Bytes32`](/docs/reference/scalars/#bytes32)
+
+The Merkle tree root of the bytecode that is being uploaded.
+
+`subsectionIndex`: [`U16`](/docs/reference/scalars/#u16)
+
+The index of the subsection of the bytecode.
+
+`subsectionsNumber`: [`U16`](/docs/reference/scalars/#u16)
+
+The total number of subsections that the bytecode was divided into.
+
+`proofSet`: [`[Bytes32!]`](/docs/reference/scalars/#bytes32)
+
+The proof set helps to verify the connection of the subsection to the `root`.
+
+`upgradePurpose`: [`UpgradePurpose`](/docs/reference/unions/#upgradepurpose)
+
+The purpose of a network upgrade.
+
`rawPayload`: [`HexString!`](/docs/reference/scalars/#hexstring)
A hex string of the raw transaction payload.
@@ -1634,6 +1837,10 @@ The consensus parameters for a transaction.
**fields:**
+`version`: [`TxParametersVersion!`](/docs/reference/unions/#txparametersversion)
+
+The version of the consensus parameters.
+
`maxInputs`: [`U8!`](/docs/reference/scalars/#u8)
The maximum number of inputs allowed for a transaction.
@@ -1654,6 +1861,10 @@ The maximum amount of gas allowed for a transaction.
The maximum size allowed for a transaction.
+`maxBytecodeSubsections`: [`U16!`](/docs/reference/scalars/#u16)
+
+The maximum number of subsections the new executor bytecode can be broken into.
+
## `VariableOutput`
The output type for a transaction that outputs an amount that may vary based on transaction execution.
diff --git a/docs/reference/queries.mdx b/docs/reference/queries.mdx
index 553f2c1..03d872a 100644
--- a/docs/reference/queries.mdx
+++ b/docs/reference/queries.mdx
@@ -123,6 +123,16 @@ Returns a [`ContractBalanceConnection!`](/docs/reference/objects/#contractbalanc
A filter for the contract balances.
+## `estimateGasPrice`
+
+Estimates the most expensive the gas price over a given block horizon, and returns [`EstimateGasPrice!`](/docs/reference/objects/#estimategasprice).
+
+**args:**
+
+`blockHorizon`: [`U32!`](/docs/reference/scalars/#u32)
+
+The block horizon defines how many blocks in the future you are doing an estimate for.
+
## `estimatePredicates`
Estimate the predicate gas and returns a [`Transaction!`](/docs/reference/objects/#transaction).
@@ -137,15 +147,19 @@ The transaction hex string.
Returns `true` if the API is running or `false` if the API is down.
-## `messageStatus`
+## `latestGasPrice`
-Returns the [`MessageStatus`](/docs/reference/objects/#messagestatus) for a given message [`Nonce`](/docs/reference/scalars/#nonce).
+Returns the [`LatestGasPrice!`](/docs/reference/objects/#latestgasprice) of the latest block.
+
+## `message`
+
+Returns the [`Message`](/docs/reference/objects/#message) for a given message nonce.
**args:**
-`nonce`: [`Nonce`](/docs/reference/scalars/#nonce)
+`nonce`: [`Nonce!`](/docs/reference/scalars/#nonce)
-The nonce of the message.
+The message nonce.
## `messageProof`
@@ -179,10 +193,30 @@ Returns a [`MessageConnection!`](/docs/reference/objects/#message) for an array
The owner address of the messages.
+## `messageStatus`
+
+Returns the [`MessageStatus`](/docs/reference/objects/#messagestatus) for a given message [`Nonce`](/docs/reference/scalars/#nonce).
+
+**args:**
+
+`nonce`: [`Nonce`](/docs/reference/scalars/#nonce)
+
+The nonce of the message.
+
## `nodeInfo`
Returns [`NodeInfo!`](/docs/reference/objects/#nodeinfo) about the current node.
+## `relayedTransactionStatus`
+
+Returns [`RelayedTransactionStatus`](/docs/reference/unions/#relayedtransactionstatus) details for a given relayed transaction id.
+
+**args:**
+
+`id`: [`RelayedTransactionId!`](/docs/reference/scalars/#relayedtransactionid)
+
+The ID for the relayed transaction.
+
## `transaction`
Returns [`Transaction`](/docs/reference/objects/#transaction) details for a given transaction id.
@@ -191,7 +225,7 @@ Returns [`Transaction`](/docs/reference/objects/#transaction) details for a give
`id`: [`TransactionId!`](/docs/reference/scalars/#transactionid)
-The id for the transaction.
+The ID for the transaction.
## `transactions`
diff --git a/docs/reference/scalars.mdx b/docs/reference/scalars.mdx
index 6fed9c7..dcb9951 100644
--- a/docs/reference/scalars.mdx
+++ b/docs/reference/scalars.mdx
@@ -33,6 +33,10 @@ A way to pass in bytes as hex data. This is used for variable byte length types.
A random or pseudo-random number generated for a single use to ensure data freshness and prevent replay attacks.
+## `RelayedTransactionId`
+
+The ID for a relayed transaction.
+
## `Salt`
Sometimes referred to as a nonce. A unique, random value used to distinguish two things that are otherwise identical. This is used in contract deployments so you can deploy contracts that are otherwise exactly the same.
@@ -53,9 +57,9 @@ A unique 32 byte hash identifier for a transaction.
The location of the transaction in the block. It can be used by UTXOs as a reference to the transaction or by the transaction itself to make it unique.
-## `U8`
+## `U16`
-Unsigned 8 bit integer.
+Unsigned 16 bit integer.
## `U32`
diff --git a/docs/reference/unions.mdx b/docs/reference/unions.mdx
index 6fa9af4..303c30f 100644
--- a/docs/reference/unions.mdx
+++ b/docs/reference/unions.mdx
@@ -36,6 +36,16 @@ Contains the dependent cost of opcodes.
[`HeavyOperation`](/docs/reference/objects/#heavyoperation): Operations that require more than 1 gas to process a single unit
+## `DryRunTransactionStatus`
+
+The status of a transaction dry run.
+
+**Types:**
+
+[`DryRunSuccessStatus`](/docs/reference/objects/#dryrunsuccessstatus): The transaction dry run was successful.
+
+[`DryRunFailureStatus`](/docs/reference/objects/#dryrunfailurestatus): The transaction dry run failed.
+
## `Input`
An input type for a transaction.
@@ -78,6 +88,14 @@ they could be set to a non-zero value.
[`ContractCreated`](/docs/reference/objects/#contractcreated):
Indicates a contract was deployed.
+## `RelayedTransactionStatus`
+
+The status of a relayed transaction from a L1. If the transaction is valid, it will be included in part of a block. If the transaction is invalid, it will be skipped.
+
+**Types:**
+
+[`RelayedTransactionFailed`](/docs/reference/objects/#relayedtransactionfailed): Details about why the relayed transaction failed.
+
## `TransactionStatus`
The status type of a transaction.
@@ -91,3 +109,13 @@ The status type of a transaction.
[`SqueezedOutStatus`](/docs/reference/objects/#squeezedoutstatus): The transaction was kicked out of the mempool.
[`FailureStatus`](/docs/reference/objects/#failurestatus): The transaction has failed.
+
+## `UpgradePurpose`
+
+The purpose of a network upgrade.
+
+**Types:**
+
+[`ConsensusParametersPurpose`](/docs/reference/objects/#consensusparameterspurpose): The consensus parameters are being upgraded.
+
+[`StateTransitionPurpose`](/docs/reference/objects/#statetransitionpurpose): The state transition is being upgraded.
diff --git a/examples/Balance.tsx b/examples/Balance.tsx
index 92a4ebb..481a4c2 100644
--- a/examples/Balance.tsx
+++ b/examples/Balance.tsx
@@ -1,20 +1,6 @@
+import { BALANCE_ARGS, BALANCE_QUERY } from './queries';
import { Query } from './query';
export function Balance() {
- const query = `query Balance($address: Address, $assetId: AssetId) {
- balance(owner: $address, assetId: $assetId) {
- owner
- amount
- assetId
- }
- }`;
-
- const args = {
- address:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- assetId:
- '0x0000000000000000000000000000000000000000000000000000000000000000',
- };
-
- return ;
+ return ;
}
diff --git a/examples/Balances.tsx b/examples/Balances.tsx
index 08a2091..f261246 100644
--- a/examples/Balances.tsx
+++ b/examples/Balances.tsx
@@ -1,21 +1,6 @@
+import { BALANCES_ARGS, BALANCES_QUERY } from './queries';
import { Query } from './query';
export function Balances() {
- const query = `query Balances($filter: BalanceFilterInput) {
- balances(filter: $filter, first: 5) {
- nodes {
- amount
- assetId
- }
- }
- }`;
-
- const args = {
- filter: {
- owner:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- },
- };
-
- return ;
+ return ;
}
diff --git a/examples/BlockByHeight.tsx b/examples/BlockByHeight.tsx
index 401f34e..deb2686 100644
--- a/examples/BlockByHeight.tsx
+++ b/examples/BlockByHeight.tsx
@@ -1,15 +1,6 @@
+import { BLOCK_BY_HEIGHT_QUERY, BLOCK_BY_HEIGHT_ARGS } from './queries';
import { Query } from './query';
export function BlockByHeight() {
- const query = `query Block($height: U64) {
- block(height: $height) {
- id
- }
- }`;
-
- const args = {
- height: '3412',
- };
-
- return ;
+ return ;
}
diff --git a/examples/ContractBalance.tsx b/examples/ContractBalance.tsx
index d1c2371..c43462d 100644
--- a/examples/ContractBalance.tsx
+++ b/examples/ContractBalance.tsx
@@ -1,19 +1,6 @@
+import { CONTRACT_BALANCE_QUERY, CONTRACT_BALANCE_ARGS } from './queries';
import { Query } from './query';
export function ContractBalance() {
- const query = `query ContractBalance($contract: ContractId, $asset: AssetId) {
- contractBalance(contract: $contract, asset: $asset) {
- contract
- amount
- assetId
- }
- }`;
-
- const args = {
- contract:
- '0xc9a5366c269438d294ef942bc962dd2e6c86121e3bca00192723eb7eb58fa87d',
- asset: '0x0000000000000000000000000000000000000000000000000000000000000000',
- };
-
- return ;
+ return ;
}
diff --git a/examples/ContractBalances.tsx b/examples/ContractBalances.tsx
index 249ab2b..9a077df 100644
--- a/examples/ContractBalances.tsx
+++ b/examples/ContractBalances.tsx
@@ -1,21 +1,8 @@
+import { CONTRACT_BALANCES_ARGS, CONTRACT_BALANCES_QUERY } from './queries';
import { Query } from './query';
export function ContractBalances() {
- const query = `query ContractBalances($filter: ContractBalanceFilterInput!) {
- contractBalances(filter: $filter, first: 5) {
- nodes {
- amount
- assetId
- }
- }
- }`;
-
- const args = {
- filter: {
- contract:
- '0x0a98320d39c03337401a4e46263972a9af6ce69ec2f35a5420b1bd35784c74b1',
- },
- };
-
- return ;
+ return (
+
+ );
}
diff --git a/examples/LatestBlocks.tsx b/examples/LatestBlocks.tsx
index 41bbf0e..9377d22 100644
--- a/examples/LatestBlocks.tsx
+++ b/examples/LatestBlocks.tsx
@@ -1,70 +1,7 @@
+import { LATEST_BLOCKS_QUERY } from './queries';
import { Query } from './query';
export function LatestBlocks() {
- const query = `query LatestBlocks {
- blocks(last: 5) {
- nodes {
- id
- transactions {
- id
- inputAssetIds
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- gasPrice
- }
- }
- }
- }`;
-
const args = {};
-
- return ;
+ return ;
}
diff --git a/examples/LatestTransactions.tsx b/examples/LatestTransactions.tsx
index d7cc8d4..d6685fe 100644
--- a/examples/LatestTransactions.tsx
+++ b/examples/LatestTransactions.tsx
@@ -1,74 +1,7 @@
+import { LATEST_TRANSACTIONS_QUERY } from './queries';
import { Query } from './query';
export function LatestTransactions() {
- const query = `query LatestTransactions {
- transactions(last: 5) {
- nodes {
- id
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- status {
- __typename
- ... on FailureStatus {
- reason
- programState {
- returnType
- }
- }
- }
- }
- }
- }`;
-
const args = {};
-
- return ;
+ return ;
}
diff --git a/examples/MessageInfo.tsx b/examples/MessageInfo.tsx
index 6047fd1..9f853a3 100644
--- a/examples/MessageInfo.tsx
+++ b/examples/MessageInfo.tsx
@@ -1,23 +1,6 @@
+import { MESSAGE_INFO_ARGS, MESSAGE_INFO_QUERY } from './queries';
import { Query } from './query';
export function MessageInfo() {
- const query = `query MessageInfo($address: Address) {
- messages(owner: $address, first: 5) {
- nodes {
- amount
- sender
- recipient
- nonce
- data
- daHeight
- }
- }
- }`;
-
- const args = {
- address:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- };
-
- return ;
+ return ;
}
diff --git a/examples/Transactions.tsx b/examples/Transactions.tsx
index 4a80360..431d119 100644
--- a/examples/Transactions.tsx
+++ b/examples/Transactions.tsx
@@ -1,77 +1,6 @@
+import { TRANSACTIONS_ARGS, TRANSACTIONS_QUERY } from './queries';
import { Query } from './query';
export function Transactions() {
- const query = `query Transactions($address: Address) {
- transactionsByOwner(owner: $address, first: 5) {
- nodes {
- id
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- status {
- __typename
- ... on FailureStatus {
- reason
- programState {
- returnType
- }
- }
- }
- }
- }
- }`;
-
- const args = {
- address:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- };
-
- return ;
+ return ;
}
diff --git a/examples/queries.ts b/examples/queries.ts
new file mode 100644
index 0000000..d4784a4
--- /dev/null
+++ b/examples/queries.ts
@@ -0,0 +1,291 @@
+export const BALANCE_QUERY = `query Balance($address: Address, $assetId: AssetId) {
+ balance(owner: $address, assetId: $assetId) {
+ owner
+ amount
+ assetId
+ }
+ }`;
+
+export const BALANCE_ARGS = {
+ address: '0xce9f8d9367fc4671c0ececce7ab603f6f75d1e66082a82ad12ecdc219b308820',
+ assetId: '0x2a0d0ed9d2217ec7f32dcd9a1902ce2a66d68437aeff84e3a3cc8bebee0d2eea',
+};
+
+export const BALANCES_QUERY = `query Balances($filter: BalanceFilterInput) {
+ balances(filter: $filter, first: 5) {
+ nodes {
+ amount
+ assetId
+ }
+ }
+ }`;
+
+export const BALANCES_ARGS = {
+ filter: {
+ owner: '0xce9f8d9367fc4671c0ececce7ab603f6f75d1e66082a82ad12ecdc219b308820',
+ },
+};
+
+export const BLOCK_BY_HEIGHT_QUERY = `query Block($height: U64) {
+ block(height: $height) {
+ id
+ }
+ }`;
+
+export const BLOCK_BY_HEIGHT_ARGS = {
+ height: '3412',
+};
+
+export const CONTRACT_BALANCE_QUERY = `query ContractBalance($contract: ContractId, $asset: AssetId) {
+ contractBalance(contract: $contract, asset: $asset) {
+ contract
+ amount
+ assetId
+ }
+ }`;
+
+export const CONTRACT_BALANCE_ARGS = {
+ contract:
+ '0xf5b08689ada97df7fd2fbd67bee7dea6d219f117c1dc9345245da16fe4e99111',
+ asset: '0x2a0d0ed9d2217ec7f32dcd9a1902ce2a66d68437aeff84e3a3cc8bebee0d2eea',
+};
+
+export const CONTRACT_BALANCES_QUERY = `query ContractBalances($filter: ContractBalanceFilterInput!) {
+ contractBalances(filter: $filter, first: 5) {
+ nodes {
+ amount
+ assetId
+ }
+ }
+}`;
+
+export const CONTRACT_BALANCES_ARGS = {
+ filter: {
+ contract:
+ '0xf5b08689ada97df7fd2fbd67bee7dea6d219f117c1dc9345245da16fe4e99111',
+ },
+};
+
+export const MESSAGE_INFO_QUERY = `query MessageInfo($address: Address) {
+ messages(owner: $address, first: 5) {
+ nodes {
+ amount
+ sender
+ recipient
+ nonce
+ data
+ daHeight
+ }
+ }
+ }`;
+
+export const MESSAGE_INFO_ARGS = {
+ address: '0xce9f8d9367fc4671c0ececce7ab603f6f75d1e66082a82ad12ecdc219b308820',
+};
+
+export const LATEST_BLOCKS_QUERY = `query LatestBlocks {
+ blocks(last: 5) {
+ nodes {
+ id
+ transactions {
+ id
+ inputAssetIds
+ inputs {
+ __typename
+ ... on InputCoin {
+ owner
+ utxoId
+ amount
+ assetId
+ }
+ ... on InputContract {
+ utxoId
+ contractId
+ }
+ ... on InputMessage {
+ sender
+ recipient
+ amount
+ data
+ }
+ }
+ outputs {
+ __typename
+ ... on CoinOutput {
+ to
+ amount
+ assetId
+ }
+ ... on ContractOutput {
+ inputIndex
+ balanceRoot
+ stateRoot
+ }
+ ... on ChangeOutput {
+ to
+ amount
+ assetId
+ }
+ ... on VariableOutput {
+ to
+ amount
+ assetId
+ }
+ ... on ContractCreated {
+ contract
+ stateRoot
+ }
+ }
+ }
+ }
+ }
+ }`;
+
+export const LATEST_TRANSACTIONS_QUERY = `query LatestTransactions {
+ transactions(last: 5) {
+ nodes {
+ id
+ inputs {
+ __typename
+ ... on InputCoin {
+ owner
+ utxoId
+ amount
+ assetId
+ }
+ ... on InputContract {
+ utxoId
+ contractId
+ }
+ ... on InputMessage {
+ sender
+ recipient
+ amount
+ data
+ }
+ }
+ outputs {
+ __typename
+ ... on CoinOutput {
+ to
+ amount
+ assetId
+ }
+ ... on ContractOutput {
+ inputIndex
+ balanceRoot
+ stateRoot
+ }
+ ... on ChangeOutput {
+ to
+ amount
+ assetId
+ }
+ ... on VariableOutput {
+ to
+ amount
+ assetId
+ }
+ ... on ContractCreated {
+ contract
+ stateRoot
+ }
+ }
+ status {
+ __typename
+ ... on FailureStatus {
+ reason
+ programState {
+ returnType
+ }
+ }
+ }
+ }
+ }
+ }`;
+
+export const TRANSACTIONS_QUERY = `query Transactions($address: Address) {
+ transactionsByOwner(owner: $address, first: 5) {
+ nodes {
+ id
+ inputs {
+ __typename
+ ... on InputCoin {
+ owner
+ utxoId
+ amount
+ assetId
+ }
+ ... on InputContract {
+ utxoId
+ contractId
+ }
+ ... on InputMessage {
+ sender
+ recipient
+ amount
+ data
+ }
+ }
+ outputs {
+ __typename
+ ... on CoinOutput {
+ to
+ amount
+ assetId
+ }
+ ... on ContractOutput {
+ inputIndex
+ balanceRoot
+ stateRoot
+ }
+ ... on ChangeOutput {
+ to
+ amount
+ assetId
+ }
+ ... on VariableOutput {
+ to
+ amount
+ assetId
+ }
+ ... on ContractCreated {
+ contract
+ stateRoot
+ }
+ }
+ status {
+ __typename
+ ... on FailureStatus {
+ reason
+ programState {
+ returnType
+ }
+ }
+ }
+ }
+ }
+}`;
+
+export const TRANSACTIONS_ARGS = {
+ address: '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
+};
+
+export const ALL_QUERY_CONSTANTS = {
+ BALANCE_QUERY,
+ BALANCE_ARGS,
+ BALANCES_QUERY,
+ BALANCES_ARGS,
+ BLOCK_BY_HEIGHT_QUERY,
+ BLOCK_BY_HEIGHT_ARGS,
+ CONTRACT_BALANCE_QUERY,
+ CONTRACT_BALANCE_ARGS,
+ CONTRACT_BALANCES_QUERY,
+ CONTRACT_BALANCES_ARGS,
+ MESSAGE_INFO_QUERY,
+ MESSAGE_INFO_ARGS,
+ LATEST_BLOCKS_QUERY,
+ LATEST_TRANSACTIONS_QUERY,
+ TRANSACTIONS_QUERY,
+ TRANSACTIONS_ARGS,
+};
diff --git a/examples/query.tsx b/examples/query.tsx
index c2995c7..6d20f78 100644
--- a/examples/query.tsx
+++ b/examples/query.tsx
@@ -5,6 +5,8 @@ import { ExampleBox } from '~/src/components/ExampleBox';
import { Paragraph } from '~/src/components/Paragraph';
import { Pre } from '~/src/components/Pre';
+import { TESTNET_ENDPOINT } from '../src/constants';
+
interface QueryProps {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
query: any;
@@ -13,12 +15,13 @@ interface QueryProps {
}
export function Query(props: QueryProps) {
- const [resp, setResp] = useState();
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const [resp, setResp] = useState();
const [loading, setLoading] = useState(false);
function runQuery() {
setLoading(true);
- fetch('https://beta-5.fuel.network/graphql', {
+ fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
diff --git a/examples/tests/balance.test.ts b/examples/tests/balance.test.ts
index 050049c..91cf79c 100644
--- a/examples/tests/balance.test.ts
+++ b/examples/tests/balance.test.ts
@@ -1,36 +1,29 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
import { Client, cacheExchange, fetchExchange } from 'urql';
import 'isomorphic-fetch';
+import { TESTNET_ENDPOINT } from '~/src/constants';
+
+import { BALANCE_ARGS, BALANCE_QUERY } from '../queries';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
describe('Balance', () => {
test('get balance with ts', async () => {
- const BALANCE_QUERY = `query Balance($address: Address, $assetId: AssetId) {
- balance(owner: $address, assetId: $assetId) {
- owner
- amount
- assetId
- }
- }`;
-
- const args = {
- address:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- assetId:
- '0x0000000000000000000000000000000000000000000000000000000000000000',
- };
+ // BALANCE_QUERY
+
+ // BALANCE_ARGS
const getBalance = async () => {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -38,10 +31,10 @@ describe('Balance', () => {
},
body: JSON.stringify({
query: BALANCE_QUERY,
- variables: args,
+ variables: BALANCE_ARGS,
}),
});
- const json = await response.json();
+ const json: any = await response.json();
console.log('BALANCE:', json.data.balance);
expect(json.data.balance.amount).toBeTruthy();
};
@@ -50,25 +43,14 @@ describe('Balance', () => {
});
test('get balance with apollo', async () => {
- const BALANCE_QUERY = `query Balance($address: Address, $assetId: AssetId) {
- balance(owner: $address, assetId: $assetId) {
- owner
- amount
- assetId
- }
- }`;
-
- const args = {
- address:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- assetId:
- '0x0000000000000000000000000000000000000000000000000000000000000000',
- };
+ // BALANCE_QUERY
+
+ // BALANCE_ARGS
const getBalance = async () => {
const response = await apolloClient.query({
query: gql(BALANCE_QUERY),
- variables: args,
+ variables: BALANCE_ARGS,
});
console.log('BALANCE:', response.data.balance);
expect(response.data.balance.amount).toBeTruthy();
@@ -78,23 +60,14 @@ describe('Balance', () => {
});
test('get balance with urql', async () => {
- const BALANCE_QUERY = `query Balance($address: Address, $assetId: AssetId) {
- balance(owner: $address, assetId: $assetId) {
- owner
- amount
- assetId
- }
- }`;
-
- const args = {
- address:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- assetId:
- '0x0000000000000000000000000000000000000000000000000000000000000000',
- };
+ // BALANCE_QUERY
+
+ // BALANCE_ARGS
const getBalance = async () => {
- const response = await urqlClient.query(BALANCE_QUERY, args).toPromise();
+ const response = await urqlClient
+ .query(BALANCE_QUERY, BALANCE_ARGS)
+ .toPromise();
console.log('BALANCE:', response.data.balance);
expect(response.data.balance.amount).toBeTruthy();
};
diff --git a/examples/tests/balances.test.ts b/examples/tests/balances.test.ts
index 502de0f..ed9e128 100644
--- a/examples/tests/balances.test.ts
+++ b/examples/tests/balances.test.ts
@@ -1,37 +1,29 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
import { Client, cacheExchange, fetchExchange } from 'urql';
import 'isomorphic-fetch';
+import { TESTNET_ENDPOINT } from '~/src/constants';
+
+import { BALANCES_ARGS, BALANCES_QUERY } from '../queries';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
describe('Balances', () => {
test('get balances with ts', async () => {
- const BALANCES_QUERY = `query Balances($filter: BalanceFilterInput) {
- balances(filter: $filter, first: 5) {
- nodes {
- amount
- assetId
- }
- }
- }`;
-
- const args = {
- filter: {
- owner:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- },
- };
+ // BALANCES_QUERY
+
+ // BALANCES_ARGS
const getBalances = async () => {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -39,10 +31,10 @@ describe('Balances', () => {
},
body: JSON.stringify({
query: BALANCES_QUERY,
- variables: args,
+ variables: BALANCES_ARGS,
}),
});
- const json = await response.json();
+ const json: any = await response.json();
console.log('BALANCES:', json.data.balances);
expect(json.data.balances.nodes).toBeTruthy();
};
@@ -51,26 +43,14 @@ describe('Balances', () => {
});
test('get balances with apollo', async () => {
- const BALANCES_QUERY = `query Balances($filter: BalanceFilterInput) {
- balances(filter: $filter, first: 5) {
- nodes {
- amount
- assetId
- }
- }
- }`;
-
- const args = {
- filter: {
- owner:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- },
- };
+ // BALANCES_QUERY
+
+ // BALANCES_ARGS
const getBalances = async () => {
const response = await apolloClient.query({
query: gql(BALANCES_QUERY),
- variables: args,
+ variables: BALANCES_ARGS,
});
console.log('BALANCES:', response.data.balances);
expect(response.data.balances.nodes).toBeTruthy();
@@ -80,24 +60,14 @@ describe('Balances', () => {
});
test('get balances with urql', async () => {
- const BALANCES_QUERY = `query Balances($filter: BalanceFilterInput) {
- balances(filter: $filter, first: 5) {
- nodes {
- amount
- assetId
- }
- }
- }`;
-
- const args = {
- filter: {
- owner:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- },
- };
+ // BALANCES_QUERY
+
+ // BALANCES_ARGS
const getBalances = async () => {
- const response = await urqlClient.query(BALANCES_QUERY, args).toPromise();
+ const response = await urqlClient
+ .query(BALANCES_QUERY, BALANCES_ARGS)
+ .toPromise();
console.log('BALANCES:', response.data.balances);
expect(response.data.balances.nodes).toBeTruthy();
};
diff --git a/examples/tests/block.test.ts b/examples/tests/block.test.ts
index f00902b..9f11d0b 100644
--- a/examples/tests/block.test.ts
+++ b/examples/tests/block.test.ts
@@ -1,30 +1,29 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
import { Client, cacheExchange, fetchExchange } from 'urql';
import 'isomorphic-fetch';
+import { TESTNET_ENDPOINT } from '~/src/constants';
+
+import { BLOCK_BY_HEIGHT_ARGS, BLOCK_BY_HEIGHT_QUERY } from '../queries';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
describe('Block Info', () => {
test('get block info with ts', async () => {
- const BLOCK_BY_HEIGHT_QUERY = `
- query Block($height: U64) {
- block(height: $height) {
- id
- }
- }`;
+ // BLOCK_BY_HEIGHT_QUERY
- const args = { height: '3412' };
+ // BLOCK_BY_HEIGHT_ARGS
const getBlock = async () => {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -32,10 +31,10 @@ describe('Block Info', () => {
},
body: JSON.stringify({
query: BLOCK_BY_HEIGHT_QUERY,
- variables: args,
+ variables: BLOCK_BY_HEIGHT_ARGS,
}),
});
- const json = await response.json();
+ const json: any = await response.json();
console.log('BLOCK:', json.data.block);
expect(json.data.block.id).toBeTruthy();
};
@@ -44,19 +43,14 @@ describe('Block Info', () => {
});
test('get block info with apollo', async () => {
- const BLOCK_BY_HEIGHT_QUERY = `
- query Block($height: U64) {
- block(height: $height) {
- id
- }
- }`;
+ // BLOCK_BY_HEIGHT_QUERY
- const args = { height: '3412' };
+ // BLOCK_BY_HEIGHT_ARGS
const getBlock = async () => {
const response = await apolloClient.query({
query: gql(BLOCK_BY_HEIGHT_QUERY),
- variables: args,
+ variables: BLOCK_BY_HEIGHT_ARGS,
});
console.log('BLOCK:', response.data.block);
expect(response.data.block.id).toBeTruthy();
@@ -66,18 +60,13 @@ describe('Block Info', () => {
});
test('get block info with urql', async () => {
- const BLOCK_BY_HEIGHT_QUERY = `
- query Block($height: U64) {
- block(height: $height) {
- id
- }
- }`;
+ // BLOCK_BY_HEIGHT_QUERY
- const args = { height: '3412' };
+ // BLOCK_BY_HEIGHT_ARGS
const getBlock = async () => {
const response = await urqlClient
- .query(BLOCK_BY_HEIGHT_QUERY, args)
+ .query(BLOCK_BY_HEIGHT_QUERY, BLOCK_BY_HEIGHT_ARGS)
.toPromise();
console.log('BLOCK:', response.data.block);
expect(response.data.block.id).toBeTruthy();
diff --git a/examples/tests/contract-balance.test.ts b/examples/tests/contract-balance.test.ts
index 4a50bc6..f2d2015 100644
--- a/examples/tests/contract-balance.test.ts
+++ b/examples/tests/contract-balance.test.ts
@@ -1,36 +1,29 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
import { Client, cacheExchange, fetchExchange } from 'urql';
import 'isomorphic-fetch';
+import { TESTNET_ENDPOINT } from '~/src/constants';
+
+import { CONTRACT_BALANCE_ARGS, CONTRACT_BALANCE_QUERY } from '../queries';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
describe('Contract Balance', () => {
test('get contract balance with ts', async () => {
- const CONTRACT_BALANCE_QUERY = `query ContractBalance($contract: ContractId, $asset: AssetId) {
- contractBalance(contract: $contract, asset: $asset) {
- contract
- amount
- assetId
- }
- }`;
-
- const args = {
- contract:
- '0xc9a5366c269438d294ef942bc962dd2e6c86121e3bca00192723eb7eb58fa87d',
- asset:
- '0x0000000000000000000000000000000000000000000000000000000000000000',
- };
+ // CONTRACT_BALANCE_QUERY
+
+ // CONTRACT_BALANCE_ARGS
const getContractBalance = async () => {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -38,10 +31,10 @@ describe('Contract Balance', () => {
},
body: JSON.stringify({
query: CONTRACT_BALANCE_QUERY,
- variables: args,
+ variables: CONTRACT_BALANCE_ARGS,
}),
});
- const json = await response.json();
+ const json: any = await response.json();
console.log('CONTRACT BALANCE:', json.data.contractBalance);
expect(json.data.contractBalance.amount).toBeTruthy();
};
@@ -50,25 +43,14 @@ describe('Contract Balance', () => {
});
test('get contract balance with apollo', async () => {
- const CONTRACT_BALANCE_QUERY = `query ContractBalance($contract: ContractId, $asset: AssetId) {
- contractBalance(contract: $contract, asset: $asset) {
- contract
- amount
- assetId
- }
- }`;
-
- const args = {
- contract:
- '0xc9a5366c269438d294ef942bc962dd2e6c86121e3bca00192723eb7eb58fa87d',
- asset:
- '0x0000000000000000000000000000000000000000000000000000000000000000',
- };
+ // CONTRACT_BALANCE_QUERY
+
+ // CONTRACT_BALANCE_ARGS
const getContractBalance = async () => {
const response = await apolloClient.query({
query: gql(CONTRACT_BALANCE_QUERY),
- variables: args,
+ variables: CONTRACT_BALANCE_ARGS,
});
console.log('CONTRACT BALANCE:', response.data.contractBalance);
expect(response.data.contractBalance.amount).toBeTruthy();
@@ -78,24 +60,13 @@ describe('Contract Balance', () => {
});
test('get contract balance with urql', async () => {
- const CONTRACT_BALANCE_QUERY = `query ContractBalance($contract: ContractId, $asset: AssetId) {
- contractBalance(contract: $contract, asset: $asset) {
- contract
- amount
- assetId
- }
- }`;
-
- const args = {
- contract:
- '0xc9a5366c269438d294ef942bc962dd2e6c86121e3bca00192723eb7eb58fa87d',
- asset:
- '0x0000000000000000000000000000000000000000000000000000000000000000',
- };
+ // CONTRACT_BALANCE_QUERY
+
+ // CONTRACT_BALANCE_ARGS
const getContractBalance = async () => {
const response = await urqlClient
- .query(CONTRACT_BALANCE_QUERY, args)
+ .query(CONTRACT_BALANCE_QUERY, CONTRACT_BALANCE_ARGS)
.toPromise();
console.log('CONTRACT BALANCE:', response.data.contractBalance);
expect(response.data.contractBalance.amount).toBeTruthy();
diff --git a/examples/tests/contract-balances.test.ts b/examples/tests/contract-balances.test.ts
index 554d4c8..b4f51d0 100644
--- a/examples/tests/contract-balances.test.ts
+++ b/examples/tests/contract-balances.test.ts
@@ -1,38 +1,29 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
import { Client, cacheExchange, fetchExchange } from 'urql';
import 'isomorphic-fetch';
+import { TESTNET_ENDPOINT } from '~/src/constants';
+
+import { CONTRACT_BALANCES_ARGS, CONTRACT_BALANCES_QUERY } from '../queries';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
describe('Contract balances', () => {
test('get contract balances with ts', async () => {
- const CONTRACT_BALANCES_QUERY = `
- query ContractBalances($filter: ContractBalanceFilterInput!) {
- contractBalances(filter: $filter, first: 5) {
- nodes {
- amount
- assetId
- }
- }
- }`;
-
- const args = {
- filter: {
- contract:
- '0x0a98320d39c03337401a4e46263972a9af6ce69ec2f35a5420b1bd35784c74b1',
- },
- };
+ // CONTRACT_BALANCES_QUERY
+
+ // CONTRACT_BALANCES_ARGS
const getContractBalances = async () => {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -40,10 +31,10 @@ describe('Contract balances', () => {
},
body: JSON.stringify({
query: CONTRACT_BALANCES_QUERY,
- variables: args,
+ variables: CONTRACT_BALANCES_ARGS,
}),
});
- const json = await response.json();
+ const json: any = await response.json();
console.log('CONTRACT BALANCES:', json.data.contractBalances);
expect(json.data.contractBalances.nodes).toBeTruthy();
};
@@ -52,27 +43,14 @@ describe('Contract balances', () => {
});
test('get contract balances with apollo', async () => {
- const CONTRACT_BALANCES_QUERY = `
- query ContractBalances($filter: ContractBalanceFilterInput!) {
- contractBalances(filter: $filter, first: 5) {
- nodes {
- amount
- assetId
- }
- }
- }`;
-
- const args = {
- filter: {
- contract:
- '0x0a98320d39c03337401a4e46263972a9af6ce69ec2f35a5420b1bd35784c74b1',
- },
- };
+ // CONTRACT_BALANCES_QUERY
+
+ // CONTRACT_BALANCES_ARGS
const getContractBalances = async () => {
const response = await apolloClient.query({
query: gql(CONTRACT_BALANCES_QUERY),
- variables: args,
+ variables: CONTRACT_BALANCES_ARGS,
});
console.log('CONTRACT BALANCES:', response.data.contractBalances);
expect(response.data.contractBalances.nodes).toBeTruthy();
@@ -82,26 +60,13 @@ describe('Contract balances', () => {
});
test('get contract balances with urql', async () => {
- const CONTRACT_BALANCES_QUERY = `
- query ContractBalances($filter: ContractBalanceFilterInput!) {
- contractBalances(filter: $filter, first: 5) {
- nodes {
- amount
- assetId
- }
- }
- }`;
-
- const args = {
- filter: {
- contract:
- '0x0a98320d39c03337401a4e46263972a9af6ce69ec2f35a5420b1bd35784c74b1',
- },
- };
+ // CONTRACT_BALANCES_QUERY
+
+ // CONTRACT_BALANCES_ARGS
const getContractBalances = async () => {
const response = await urqlClient
- .query(CONTRACT_BALANCES_QUERY, args)
+ .query(CONTRACT_BALANCES_QUERY, CONTRACT_BALANCES_ARGS)
.toPromise();
console.log('CONTRACT BALANCES:', response.data.contractBalances);
expect(response.data.contractBalances.nodes).toBeTruthy();
diff --git a/examples/tests/latest-blocks.test.ts b/examples/tests/latest-blocks.test.ts
index 3c0a698..2dd8416 100644
--- a/examples/tests/latest-blocks.test.ts
+++ b/examples/tests/latest-blocks.test.ts
@@ -1,84 +1,27 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
import { Client, cacheExchange, fetchExchange } from 'urql';
import 'isomorphic-fetch';
+import { TESTNET_ENDPOINT } from '~/src/constants';
+
+import { LATEST_BLOCKS_QUERY } from '../queries';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
describe('Latest blocks', () => {
test('get latest blocks with ts', async () => {
- const LATEST_BLOCKS_QUERY = `query LatestBlocks {
- blocks(last: 5) {
- nodes {
- id
- transactions {
- id
- inputAssetIds
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- gasPrice
- }
- }
- }
- }`;
+ // LATEST_BLOCKS_QUERY
const getLatestBlocks = async () => {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -88,7 +31,7 @@ describe('Latest blocks', () => {
query: LATEST_BLOCKS_QUERY,
}),
});
- const json = await response.json();
+ const json: any = await response.json();
console.log('BLOCKS:', json.data.blocks);
expect(json.data.blocks.nodes.length).toBeTruthy();
};
@@ -97,68 +40,7 @@ describe('Latest blocks', () => {
});
test('get latest blocks with apollo', async () => {
- const LATEST_BLOCKS_QUERY = `query LatestBlocks {
- blocks(last: 5) {
- nodes {
- id
- transactions {
- id
- inputAssetIds
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- gasPrice
- }
- }
- }
- }`;
+ // LATEST_BLOCKS_QUERY
const getLatestBlocks = async () => {
const response = await apolloClient.query({
@@ -172,68 +54,7 @@ describe('Latest blocks', () => {
});
test('get latest blocks with urql', async () => {
- const LATEST_BLOCKS_QUERY = `query LatestBlocks {
- blocks(last: 5) {
- nodes {
- id
- transactions {
- id
- inputAssetIds
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- gasPrice
- }
- }
- }
- }`;
+ // LATEST_BLOCKS_QUERY
const getLatestBlocks = async () => {
const response = await urqlClient
diff --git a/examples/tests/latest-transactions.test.ts b/examples/tests/latest-transactions.test.ts
index 290b946..f122601 100644
--- a/examples/tests/latest-transactions.test.ts
+++ b/examples/tests/latest-transactions.test.ts
@@ -1,89 +1,27 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
import { Client, cacheExchange, fetchExchange } from 'urql';
import 'isomorphic-fetch';
+import { TESTNET_ENDPOINT } from '~/src/constants';
+
+import { LATEST_TRANSACTIONS_QUERY } from '../queries';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
describe('Latest transactions', () => {
test('get latest transactions with ts', async () => {
- const LATEST_TRANSACTIONS_QUERY = `
- query LatestTransactions {
- transactions(last: 5) {
- nodes {
- id
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- status {
- __typename
- ... on FailureStatus {
- reason
- programState {
- returnType
- }
- }
- }
- }
- }
- }`;
+ // LATEST_TRANSACTIONS_QUERY
const getLatestTransactions = async () => {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -93,7 +31,7 @@ describe('Latest transactions', () => {
query: LATEST_TRANSACTIONS_QUERY,
}),
});
- const json = await response.json();
+ const json: any = await response.json();
console.log('TRANSACTIONS:', json.data.transactions);
expect(json.data.transactions.nodes.length).toBeTruthy();
};
@@ -102,73 +40,7 @@ describe('Latest transactions', () => {
});
test('get latest transactions with apollo', async () => {
- const LATEST_TRANSACTIONS_QUERY = `
- query LatestTransactions {
- transactions(last: 5) {
- nodes {
- id
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- status {
- __typename
- ... on FailureStatus {
- reason
- programState {
- returnType
- }
- }
- }
- }
- }
- }`;
+ // LATEST_TRANSACTIONS_QUERY
const getLatestTransactions = async () => {
const response = await apolloClient.query({
@@ -182,73 +54,7 @@ describe('Latest transactions', () => {
});
test('get latest transactions with urql', async () => {
- const LATEST_TRANSACTIONS_QUERY = `
- query LatestTransactions {
- transactions(last: 5) {
- nodes {
- id
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- status {
- __typename
- ... on FailureStatus {
- reason
- programState {
- returnType
- }
- }
- }
- }
- }
- }`;
+ // LATEST_TRANSACTIONS_QUERY
const getLatestTransactions = async () => {
const response = await urqlClient
diff --git a/examples/tests/messages.test.ts b/examples/tests/messages.test.ts
index 8a411a9..a9953e5 100644
--- a/examples/tests/messages.test.ts
+++ b/examples/tests/messages.test.ts
@@ -1,51 +1,40 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
import { Client, cacheExchange, fetchExchange } from 'urql';
import 'isomorphic-fetch';
+import { TESTNET_ENDPOINT } from '~/src/constants';
+
+import { MESSAGE_INFO_ARGS, MESSAGE_INFO_QUERY } from '../queries';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
describe('Messages', () => {
test('get messages with ts', async () => {
- const MESSAGES_QUERY = `
- query MessageInfo($address: Address) {
- messages(owner: $address, first: 5) {
- nodes {
- amount
- sender
- recipient
- nonce
- data
- daHeight
- }
- }
- }`;
-
- const args = {
- address:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- };
+ // MESSAGE_INFO_QUERY
+
+ // MESSAGE_INFO_ARGS
const getMessages = async () => {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
- query: MESSAGES_QUERY,
- variables: args,
+ query: MESSAGE_INFO_QUERY,
+ variables: MESSAGE_INFO_ARGS,
}),
});
- const json = await response.json();
+ const json: any = await response.json();
console.log('MESSAGES:', json.data.messages);
expect(json.data.messages.nodes).toBeTruthy();
};
@@ -54,30 +43,14 @@ describe('Messages', () => {
});
test('get messages with apollo', async () => {
- const MESSAGES_QUERY = `
- query MessageInfo($address: Address) {
- messages(owner: $address, first: 5) {
- nodes {
- amount
- sender
- recipient
- nonce
- data
- daHeight
-
- }
- }
- }`;
-
- const args = {
- address:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- };
+ // MESSAGE_INFO_QUERY
+
+ // MESSAGE_INFO_ARGS
const getMessages = async () => {
const response = await apolloClient.query({
- query: gql(MESSAGES_QUERY),
- variables: args,
+ query: gql(MESSAGE_INFO_QUERY),
+ variables: MESSAGE_INFO_ARGS,
});
console.log('MESSAGES:', response.data.messages);
expect(response.data.messages.nodes).toBeTruthy();
@@ -87,27 +60,14 @@ describe('Messages', () => {
});
test('get messages with urql', async () => {
- const MESSAGES_QUERY = `
- query MessageInfo($address: Address) {
- messages(owner: $address, first: 5) {
- nodes {
- amount
- sender
- recipient
- nonce
- data
- daHeight
- }
- }
- }`;
-
- const args = {
- address:
- '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871',
- };
+ // MESSAGE_INFO_QUERY
+
+ // MESSAGE_INFO_ARGS
const getMessages = async () => {
- const response = await urqlClient.query(MESSAGES_QUERY, args).toPromise();
+ const response = await urqlClient
+ .query(MESSAGE_INFO_QUERY, MESSAGE_INFO_ARGS)
+ .toPromise();
console.log('MESSAGES:', response.data.messages);
expect(response.data.messages.nodes).toBeTruthy();
};
diff --git a/examples/tests/transactions-by-owner.test.ts b/examples/tests/transactions-by-owner.test.ts
index 5db50fc..d0e3fcc 100644
--- a/examples/tests/transactions-by-owner.test.ts
+++ b/examples/tests/transactions-by-owner.test.ts
@@ -1,278 +1,79 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
import { Client, cacheExchange, fetchExchange } from 'urql';
import 'isomorphic-fetch';
+import { TESTNET_ENDPOINT } from '~/src/constants';
+
+import { TRANSACTIONS_ARGS, TRANSACTIONS_QUERY } from '../queries';
const apolloClient = new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: TESTNET_ENDPOINT,
cache: new InMemoryCache(),
});
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: TESTNET_ENDPOINT,
exchanges: [cacheExchange, fetchExchange],
});
describe('Transactions by owner', () => {
test('get transactions with ts', async () => {
- const TRANSACTIONS_BY_OWNER_QUERY = `
- query Transactions($address: Address) {
- transactionsByOwner(owner: $address, first: 5) {
- nodes {
- id
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- status {
- __typename
- ... on FailureStatus {
- reason
- programState {
- returnType
- }
- }
- }
- }
- }
- }`;
+ // TRANSACTIONS_QUERY
- const args = {
- address:
- '0x44f640c8ed0d0b76fa7a029972e9db1ce92386b8e4df4d789e026443cb5f0d91',
- };
+ // TRANSACTIONS_ARGS
const getTransactions = async () => {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch(TESTNET_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
- query: TRANSACTIONS_BY_OWNER_QUERY,
- variables: args,
+ query: TRANSACTIONS_QUERY,
+ variables: TRANSACTIONS_ARGS,
}),
});
- const json = await response.json();
+ const json: any = await response.json();
console.log('TRANSACTIONS:', json.data.transactionsByOwner);
- expect(json.data.transactionsByOwner.nodes.length).toBeTruthy();
+ expect(Array.isArray(json.data.transactionsByOwner.nodes)).toBeTruthy();
};
await getTransactions();
});
test('get transactions with apollo', async () => {
- const TRANSACTIONS_BY_OWNER_QUERY = `
- query Transactions($address: Address) {
- transactionsByOwner(owner: $address, first: 5) {
- nodes {
- id
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- status {
- __typename
- ... on FailureStatus {
- reason
- programState {
- returnType
- }
- }
- }
- }
- }
- }`;
+ // TRANSACTIONS_QUERY
- const args = {
- address:
- '0x44f640c8ed0d0b76fa7a029972e9db1ce92386b8e4df4d789e026443cb5f0d91',
- };
+ // TRANSACTIONS_ARGS
const getTransactions = async () => {
const response = await apolloClient.query({
- query: gql(TRANSACTIONS_BY_OWNER_QUERY),
- variables: args,
+ query: gql(TRANSACTIONS_QUERY),
+ variables: TRANSACTIONS_ARGS,
});
console.log('TRANSACTIONS:', response.data.transactionsByOwner);
- expect(response.data.transactionsByOwner.nodes.length).toBeTruthy();
+ expect(
+ Array.isArray(response.data.transactionsByOwner.nodes)
+ ).toBeTruthy();
};
await getTransactions();
});
test('get transactions with urql', async () => {
- const TRANSACTIONS_BY_OWNER_QUERY = `
- query Transactions($address: Address) {
- transactionsByOwner(owner: $address, first: 5) {
- nodes {
- id
- inputs {
- __typename
- ... on InputCoin {
- owner
- utxoId
- amount
- assetId
- }
- ... on InputContract {
- utxoId
- contract {
- id
- }
- }
- ... on InputMessage {
- sender
- recipient
- amount
- data
- }
- }
- outputs {
- __typename
- ... on CoinOutput {
- to
- amount
- assetId
- }
- ... on ContractOutput {
- inputIndex
- balanceRoot
- stateRoot
- }
- ... on ChangeOutput {
- to
- amount
- assetId
- }
- ... on VariableOutput {
- to
- amount
- assetId
- }
- ... on ContractCreated {
- contract {
- id
- }
- stateRoot
- }
- }
- status {
- __typename
- ... on FailureStatus {
- reason
- programState {
- returnType
- }
- }
- }
- }
- }
- }`;
+ // TRANSACTIONS_QUERY
- const args = {
- address:
- '0x44f640c8ed0d0b76fa7a029972e9db1ce92386b8e4df4d789e026443cb5f0d91',
- };
+ // TRANSACTIONS_ARGS
const getTransactions = async () => {
const response = await urqlClient
- .query(TRANSACTIONS_BY_OWNER_QUERY, args)
+ .query(TRANSACTIONS_QUERY, TRANSACTIONS_ARGS)
.toPromise();
console.log('TRANSACTIONS:', response.data.transactionsByOwner);
- expect(response.data.transactionsByOwner.nodes.length).toBeTruthy();
+ expect(
+ Array.isArray(response.data.transactionsByOwner.nodes)
+ ).toBeTruthy();
};
await getTransactions();
diff --git a/jest.examples.ts b/jest.examples.ts
index afee542..44f9a0f 100644
--- a/jest.examples.ts
+++ b/jest.examples.ts
@@ -11,6 +11,10 @@ const config: JestConfigWithTsJest = {
},
testTimeout: 100000,
verbose: true,
+ moduleNameMapper: {
+ // Maps all imports starting with "~/" to the correct directory
+ '^~/(.*)$': '/$1',
+ },
};
export default config;
diff --git a/package-lock.json b/package-lock.json
index ba4f43c..9164582 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,7 +8,7 @@
"name": "docs",
"version": "0.0.1",
"dependencies": {
- "@apollo/client": "^3.8.6",
+ "@apollo/client": "^3.9.11",
"@docsearch/css": "^3.5.2",
"@docsearch/react": "3.5.2",
"@fuel-ui/css": "0.21.0-pr-305-04b8434",
@@ -22,6 +22,7 @@
"@mdx-js/react": "^2.3.0",
"acorn": "^8.10.0",
"acorn-loose": "^8.3.0",
+ "acorn-typescript": "^1.4.13",
"acorn-walk": "^8.2.0",
"cookie": "^0.5.0",
"dotenv": "^16.3.1",
@@ -60,7 +61,7 @@
"unified": "^10.1.2",
"unist-util-visit": "^5.0.0",
"updates": "^15.0.2",
- "urql": "^4.0.5",
+ "urql": "^4.0.7",
"vfile": "^6.0.1"
},
"devDependencies": {
@@ -86,9 +87,9 @@
}
},
"node_modules/@0no-co/graphql.web": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/@0no-co/graphql.web/-/graphql.web-1.0.4.tgz",
- "integrity": "sha512-W3ezhHGfO0MS1PtGloaTpg0PbaT8aZSmmaerL7idtU5F7oCI+uu25k+MsMS31BVFlp4aMkHSrNRxiD72IlK8TA==",
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/@0no-co/graphql.web/-/graphql.web-1.0.6.tgz",
+ "integrity": "sha512-KZ7TnwMcQJcFgzjoY623AVxtlDQonkqp3rSz0wb15/jHPyU1v5gynUibEpuutDeoyGJ5Tp+FwxjGyDGDwq3vIw==",
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
},
@@ -277,18 +278,19 @@
}
},
"node_modules/@apollo/client": {
- "version": "3.8.6",
- "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.8.6.tgz",
- "integrity": "sha512-FnHg3vhQP8tQzgBs6oTJCFFIbovelDGYujj6MK7CJneiHf62TJstCIO0Ot4A1h7XrgFEtgl8a/OgajQWqrTuYw==",
+ "version": "3.9.11",
+ "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.9.11.tgz",
+ "integrity": "sha512-H7e9m7cRcFO93tokwzqrsbnfKorkpV24xU30hFH5u2g6B+c1DMo/ouyF/YrBPdrTzqxQCjTUmds/FLmJ7626GA==",
"dependencies": {
"@graphql-typed-document-node/core": "^3.1.1",
- "@wry/context": "^0.7.3",
+ "@wry/caches": "^1.0.0",
"@wry/equality": "^0.5.6",
- "@wry/trie": "^0.4.3",
+ "@wry/trie": "^0.5.0",
"graphql-tag": "^2.12.6",
"hoist-non-react-statics": "^3.3.2",
- "optimism": "^0.17.5",
+ "optimism": "^0.18.0",
"prop-types": "^15.7.2",
+ "rehackt": "0.0.6",
"response-iterator": "^0.2.6",
"symbol-observable": "^4.0.0",
"ts-invariant": "^0.10.3",
@@ -296,7 +298,7 @@
"zen-observable-ts": "^1.2.5"
},
"peerDependencies": {
- "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
+ "graphql": "^15.0.0 || ^16.0.0",
"graphql-ws": "^5.5.5",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -7287,18 +7289,29 @@
}
},
"node_modules/@urql/core": {
- "version": "4.1.4",
- "resolved": "https://registry.npmjs.org/@urql/core/-/core-4.1.4.tgz",
- "integrity": "sha512-wFm67yljv4uFAWNtPwcS1NMhF/n+p/68i+kZU6R1dPxhfq2nBW0142p4szeZsBDrtO7pBdOhp7YeSZROFFlXZg==",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/@urql/core/-/core-5.0.0.tgz",
+ "integrity": "sha512-kFkZxusq/VBQKEUcQFtf7AilMotLO+oGpE4WFhCiminZm8ZU2aulXSDWla50TaD0pj704FnWlXts6lRm0uHdDg==",
"dependencies": {
- "@0no-co/graphql.web": "^1.0.1",
+ "@0no-co/graphql.web": "^1.0.5",
"wonka": "^6.3.2"
}
},
+ "node_modules/@wry/caches": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@wry/caches/-/caches-1.0.1.tgz",
+ "integrity": "sha512-bXuaUNLVVkD20wcGBWRyo7j9N3TxePEWFZj2Y+r9OoUzfqmavM84+mFykRicNsBqatba5JLay1t48wxaXaWnlA==",
+ "dependencies": {
+ "tslib": "^2.3.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/@wry/context": {
- "version": "0.7.3",
- "resolved": "https://registry.npmjs.org/@wry/context/-/context-0.7.3.tgz",
- "integrity": "sha512-Nl8WTesHp89RF803Se9X3IiHjdmLBrIvPMaJkl+rKVJAYyPsz1TEUbu89943HpvujtSJgDUx9W4vZw3K1Mr3sA==",
+ "version": "0.7.4",
+ "resolved": "https://registry.npmjs.org/@wry/context/-/context-0.7.4.tgz",
+ "integrity": "sha512-jmT7Sb4ZQWI5iyu3lobQxICu2nC/vbUhP0vIdd6tHC9PTfenmRmuIFqktc6GH9cgi+ZHnsLWPvfSvc4DrYmKiQ==",
"dependencies": {
"tslib": "^2.3.0"
},
@@ -7307,9 +7320,9 @@
}
},
"node_modules/@wry/equality": {
- "version": "0.5.6",
- "resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.5.6.tgz",
- "integrity": "sha512-D46sfMTngaYlrH+OspKf8mIJETntFnf6Hsjb0V41jAXJ7Bx2kB8Rv8RCUujuVWYttFtHkUNp7g+FwxNQAr6mXA==",
+ "version": "0.5.7",
+ "resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.5.7.tgz",
+ "integrity": "sha512-BRFORjsTuQv5gxcXsuDXx6oGRhuVsEGwZy6LOzRRfgu+eSfxbhUQ9L9YtSEIuIjY/o7g3iWFjrc5eSY1GXP2Dw==",
"dependencies": {
"tslib": "^2.3.0"
},
@@ -7318,9 +7331,9 @@
}
},
"node_modules/@wry/trie": {
- "version": "0.4.3",
- "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.4.3.tgz",
- "integrity": "sha512-I6bHwH0fSf6RqQcnnXLJKhkSXG45MFral3GxPaY4uAl0LYDZM+YDVDAiU9bYwjTuysy1S0IeecWtmq1SZA3M1w==",
+ "version": "0.5.0",
+ "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.5.0.tgz",
+ "integrity": "sha512-FNoYzHawTMk/6KMQoEG5O4PuioX19UbwdQKF44yw0nLfOypfQdjtfZzo/UIJWAJ23sNIFbD1Ug9lbaDGMwbqQA==",
"dependencies": {
"tslib": "^2.3.0"
},
@@ -7380,6 +7393,14 @@
"node": ">=0.4.0"
}
},
+ "node_modules/acorn-typescript": {
+ "version": "1.4.13",
+ "resolved": "https://registry.npmjs.org/acorn-typescript/-/acorn-typescript-1.4.13.tgz",
+ "integrity": "sha512-xsc9Xv0xlVfwp2o7sQ+GCQ1PgbkdcpWdTzrwXxO3xDMTAywVS3oXVOcOHuRjAPkS4P9b+yc/qNF15460v+jp4Q==",
+ "peerDependencies": {
+ "acorn": ">=8.9.0"
+ }
+ },
"node_modules/acorn-walk": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
@@ -15801,15 +15822,27 @@
}
},
"node_modules/optimism": {
- "version": "0.17.5",
- "resolved": "https://registry.npmjs.org/optimism/-/optimism-0.17.5.tgz",
- "integrity": "sha512-TEcp8ZwK1RczmvMnvktxHSF2tKgMWjJ71xEFGX5ApLh67VsMSTy1ZUlipJw8W+KaqgOmQ+4pqwkeivY89j+4Vw==",
+ "version": "0.18.0",
+ "resolved": "https://registry.npmjs.org/optimism/-/optimism-0.18.0.tgz",
+ "integrity": "sha512-tGn8+REwLRNFnb9WmcY5IfpOqeX2kpaYJ1s6Ae3mn12AeydLkR3j+jSCmVQFoXqU8D41PAJ1RG1rCRNWmNZVmQ==",
"dependencies": {
+ "@wry/caches": "^1.0.0",
"@wry/context": "^0.7.0",
"@wry/trie": "^0.4.3",
"tslib": "^2.3.0"
}
},
+ "node_modules/optimism/node_modules/@wry/trie": {
+ "version": "0.4.3",
+ "resolved": "https://registry.npmjs.org/@wry/trie/-/trie-0.4.3.tgz",
+ "integrity": "sha512-I6bHwH0fSf6RqQcnnXLJKhkSXG45MFral3GxPaY4uAl0LYDZM+YDVDAiU9bYwjTuysy1S0IeecWtmq1SZA3M1w==",
+ "dependencies": {
+ "tslib": "^2.3.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/optionator": {
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz",
@@ -17210,6 +17243,23 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/rehackt": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/rehackt/-/rehackt-0.0.6.tgz",
+ "integrity": "sha512-l3WEzkt4ntlEc/IB3/mF6SRgNHA6zfQR7BlGOgBTOmx7IJJXojDASav+NsgXHFjHn+6RmwqsGPFgZpabWpeOdw==",
+ "peerDependencies": {
+ "@types/react": "*",
+ "react": "*"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "react": {
+ "optional": true
+ }
+ }
+ },
"node_modules/rehype-pretty-code": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/rehype-pretty-code/-/rehype-pretty-code-0.10.1.tgz",
@@ -19280,11 +19330,11 @@
"integrity": "sha512-mYFmBHCapZjtcNHW0MDq9967t+z4Dmg5CJ0KqysK3+ZbyoNOWQHksGCTWwDhxGXllkWlOc10Xfko6v4a3ucM6A=="
},
"node_modules/urql": {
- "version": "4.0.5",
- "resolved": "https://registry.npmjs.org/urql/-/urql-4.0.5.tgz",
- "integrity": "sha512-VicPBQXWicSbE+0oPzU2HMyDa//76FmwyQ7LayaYQxX97nhvMLs2ZWQdUmEzQQqvmw4YFaI0wPz1Qisp+PrZIQ==",
+ "version": "4.0.7",
+ "resolved": "https://registry.npmjs.org/urql/-/urql-4.0.7.tgz",
+ "integrity": "sha512-wnOONtZoYEobmamM5ushUBGil6UCUPd7SH5uEAqsz5Y/qBV88/2QG6jq7v6xP+413x5Lqy0h0hCGRB0KIeG6Kg==",
"dependencies": {
- "@urql/core": "^4.1.0",
+ "@urql/core": "^5.0.0",
"wonka": "^6.3.2"
},
"peerDependencies": {
diff --git a/package.json b/package.json
index afcb269..e4e384c 100644
--- a/package.json
+++ b/package.json
@@ -14,11 +14,12 @@
"lint:docs:check": "markdownlint --config .markdownlint.yaml '**/*.mdx'",
"lint:docs:fix": "markdownlint --config .markdownlint.yaml '**/*.mdx' --fix",
"test:examples": "jest -c jest.examples.ts",
+ "test:coverage": "node scripts/coverage/index.mjs",
"prettier:check": "prettier --check .",
"prettier:format": "prettier --write ."
},
"dependencies": {
- "@apollo/client": "^3.8.6",
+ "@apollo/client": "^3.9.11",
"@docsearch/css": "^3.5.2",
"@docsearch/react": "3.5.2",
"@fuel-ui/css": "0.21.0-pr-305-04b8434",
@@ -32,6 +33,7 @@
"@mdx-js/react": "^2.3.0",
"acorn": "^8.10.0",
"acorn-loose": "^8.3.0",
+ "acorn-typescript": "^1.4.13",
"acorn-walk": "^8.2.0",
"cookie": "^0.5.0",
"dotenv": "^16.3.1",
@@ -70,7 +72,7 @@
"unified": "^10.1.2",
"unist-util-visit": "^5.0.0",
"updates": "^15.0.2",
- "urql": "^4.0.5",
+ "urql": "^4.0.7",
"vfile": "^6.0.1"
},
"devDependencies": {
diff --git a/scripts/coverage/utils.mjs b/scripts/coverage/utils.mjs
index 8d772d8..e94ac07 100644
--- a/scripts/coverage/utils.mjs
+++ b/scripts/coverage/utils.mjs
@@ -38,7 +38,7 @@ export async function getHeadings(filepath) {
}
export async function request(query) {
- const response = await fetch('https://beta-5.fuel.network/graphql', {
+ const response = await fetch('https://testnet.fuel.network/v1/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
diff --git a/spell-check-custom-words.txt b/spell-check-custom-words.txt
index cf3e927..a145d5e 100644
--- a/spell-check-custom-words.txt
+++ b/spell-check-custom-words.txt
@@ -75,4 +75,6 @@ EOA
args
breakpoint
PeerInfo
-Unix
\ No newline at end of file
+Unix
+incentivize
+devnet
\ No newline at end of file
diff --git a/src/components/CodeExamples.tsx b/src/components/CodeExamples.tsx
index e9793f8..e739893 100644
--- a/src/components/CodeExamples.tsx
+++ b/src/components/CodeExamples.tsx
@@ -1,7 +1,7 @@
import { cssObj } from '@fuel-ui/css';
import { Link, Tabs, Box } from '@fuel-ui/react';
-import { REPO_LINK } from '../constants';
+import { REPO_LINK, TESTNET_ENDPOINT } from '../constants';
import { Pre } from './Pre';
@@ -58,7 +58,7 @@ export function CodeExamples({
const apolloImport = `import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const apolloClient= new ApolloClient({
- uri: 'https://beta-5.fuel.network/graphql',
+ uri: '${TESTNET_ENDPOINT}',
cache: new InMemoryCache(),
});
@@ -67,7 +67,7 @@ const apolloClient= new ApolloClient({
const urqlImport = `import { Client, cacheExchange, fetchExchange } from 'urql';
const urqlClient = new Client({
- url: 'https://beta-5.fuel.network/graphql',
+ url: '${TESTNET_ENDPOINT}',
exchanges: [cacheExchange, fetchExchange],
});
diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx
index 985efc9..9bdfe1d 100644
--- a/src/components/Layout.tsx
+++ b/src/components/Layout.tsx
@@ -2,8 +2,9 @@ import { cssObj } from '@fuel-ui/css';
import { Box } from '@fuel-ui/react';
import Head from 'next/head';
import type { ReactNode } from 'react';
+import ogImage from '~/public/og-image.png';
-import { META_DESC, META_OGIMG } from '../constants';
+import { META_DESC, URL } from '../constants';
import { Header } from './Header';
@@ -16,6 +17,8 @@ export function Layout({ title, children }: LayoutProps) {
const titleText = title
? `${title} | Fuel GraphQL Docs`
: 'Fuel GraphQL Docs';
+ const META_OGIMG = URL + ogImage.src;
+
return (
<>
diff --git a/src/constants.ts b/src/constants.ts
index 0b80014..6b208a5 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -1,6 +1,4 @@
-import ogImage from '../public/og-image.png';
-
-const URL = 'https://graphql-docs.fuel.network/';
+export const URL = 'https://graphql-docs.fuel.network/';
export const FIELDS = ['title', 'slug', 'content', 'category'];
export const REPO_LINK = 'https://github.com/FuelLabs/fuel-graphql-docs/';
@@ -9,4 +7,4 @@ export const DEFAULT_SLUG = ['overview'];
export const META_DESC = 'Official documentation for the Fuel GraphQL API';
-export const META_OGIMG = URL + ogImage.src;
+export const TESTNET_ENDPOINT = 'https://testnet.fuel.network/v1/graphql';
diff --git a/src/lib/code-examples.ts b/src/lib/code-examples.ts
index e555c9a..e2721f5 100644
--- a/src/lib/code-examples.ts
+++ b/src/lib/code-examples.ts
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
-
-import * as acorn from 'acorn';
+import * as acornLoose from 'acorn-loose';
import * as walk from 'acorn-walk';
import fs from 'node:fs';
import { EOL } from 'os';
@@ -8,12 +7,15 @@ import path from 'path';
import * as prettier from 'prettier';
import type { Root } from 'remark-gfm';
import { visit } from 'unist-util-visit';
-import type { Parent } from 'unist-util-visit';
+import type { Parent } from 'unist-util-visit/lib';
+
+import { ALL_QUERY_CONSTANTS } from '../../examples/queries';
+import { TESTNET_ENDPOINT } from '../constants';
const ROOT_DIR = path.resolve(__dirname, '../../../');
function toAST(content: string) {
- return acorn.parse(content, {
+ return acornLoose.parse(content, {
ecmaVersion: 'latest',
sourceType: 'module',
});
@@ -34,7 +36,10 @@ function extractLines(
} else {
end = lines.length;
}
- return lines.slice(start - 1, end).join('\n');
+ return lines
+ .slice(start - 1, end)
+ .join('\n')
+ .replaceAll('TESTNET_ENDPOINT', `'${TESTNET_ENDPOINT}'`);
}
function getLineOffsets(str: string) {
@@ -63,7 +68,10 @@ function extractTestCase(source: string, testCase: string) {
if (val && val === testCase) {
const body = args[1]?.body;
content = chars.slice(body.start, body.end).join('').slice(1, -1);
- content = prettier.format(content, { parser: 'babel' }).trimEnd();
+ content = prettier
+ .format(content, { parser: 'babel' })
+ .trimEnd()
+ .replaceAll('TESTNET_ENDPOINT', `'${TESTNET_ENDPOINT}'`);
charStart = body.start;
charEnd = body.end;
}
@@ -80,6 +88,41 @@ function extractTestCase(source: string, testCase: string) {
};
}
+function addQuery(content: string) {
+ let queryLine;
+ let queryName;
+ let argsLine;
+ let argsName;
+ const lines = content.split(EOL);
+ for (let i = 0; i < lines.length; i++) {
+ const trimmed = lines[i].trim().replace('// ', '');
+ const found = Object.keys(ALL_QUERY_CONSTANTS).includes(trimmed);
+ if (found) {
+ if (trimmed.includes('QUERY')) {
+ queryLine = i;
+ queryName = trimmed;
+ } else if (trimmed.includes('ARGS')) {
+ argsLine = i;
+ argsName = trimmed;
+ }
+ }
+ }
+
+ if (queryName && queryLine !== undefined && queryLine !== null) {
+ lines[queryLine] =
+ `const ${queryName} = ` + '`' + `${ALL_QUERY_CONSTANTS[queryName]}` + '`';
+ }
+ if (argsName && argsLine) {
+ lines[argsLine] = `const ${argsName} = ${JSON.stringify(
+ ALL_QUERY_CONSTANTS[argsName],
+ null,
+ 2
+ )}`;
+ }
+
+ return lines.join('\n');
+}
+
const files = new Map();
const attrsList = new Map();
@@ -99,11 +142,11 @@ export function codeExamples(options: Options = { filepath: '' }) {
const dirname = path.relative(rootDir, path.dirname(filepath));
return function transformer(tree: Root) {
- const nodes: [any, number | null, Parent][] = [];
+ const nodes: [any, number | null, Parent][] = [];
visit(tree, 'mdxJsxFlowElement', (node: any, idx, parent) => {
if (node.name === 'CodeExamples') {
- nodes.push([node as any, idx, parent as Parent]);
+ nodes.push([node as any, idx!, parent as Parent]);
}
});
@@ -199,17 +242,17 @@ export function codeExamples(options: Options = { filepath: '' }) {
{
name: '__ts_content',
type: 'mdxJsxAttribute',
- value: ts_content,
+ value: addQuery(ts_content),
},
{
name: '__apollo_content',
type: 'mdxJsxAttribute',
- value: apollo_content,
+ value: addQuery(apollo_content),
},
{
name: '__urql_content',
type: 'mdxJsxAttribute',
- value: urql_content,
+ value: addQuery(urql_content),
},
{
name: '__filepath',
diff --git a/src/lib/code-import.ts b/src/lib/code-import.ts
index 4c726d1..c919488 100644
--- a/src/lib/code-import.ts
+++ b/src/lib/code-import.ts
@@ -10,6 +10,8 @@ import type { Root } from 'remark-gfm';
import { visit } from 'unist-util-visit';
import type { Parent } from 'unist-util-visit';
+import { TESTNET_ENDPOINT } from '../constants';
+
const ROOT_DIR = path.resolve(__dirname, '../../../../../../../');
function toAST(content: string) {
@@ -103,10 +105,18 @@ export function codeImport(options: Options = { filepath: '' }) {
visit(tree, 'mdxJsxFlowElement', (node: any, idx, parent) => {
if (node.name === 'CodeImport') {
- nodes.push([node as any, idx, parent as Parent]);
+ nodes.push([node as any, idx!, parent as Parent]);
}
});
+ visit(tree, '', (node: any, _idx, _parent) => {
+ if (node.type === 'code' && node.value.includes('TESTNET_ENDPOINT'))
+ node.value = node.value.replaceAll(
+ 'TESTNET_ENDPOINT',
+ `'${TESTNET_ENDPOINT}'`
+ );
+ });
+
nodes.forEach(([node]) => {
const attr = node.attributes;
let content = '';
diff --git a/tsconfig.json b/tsconfig.json
index 72c1785..bd036d2 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,6 +2,7 @@
"extends": "@fuels/ts-config/base.json",
"compilerOptions": {
"types": ["@fuel-wallet/sdk", "jest"],
+ "lib": ["es2021"],
"plugins": [{ "name": "next" }],
"allowJs": true,
"noEmit": true,