From 31e5074d1cb4bd7f292dda080d43b4e307aab0af Mon Sep 17 00:00:00 2001 From: Call Delegation Date: Wed, 27 Dec 2023 17:18:17 -0500 Subject: [PATCH 01/13] Beta 5 updatesa --- docs/overview.mdx | 6 + docs/querying-from-a-dapp.mdx | 6 +- docs/reference/mutations.mdx | 74 +++++ docs/reference/objects.mdx | 280 +++++++++++++++---- docs/reference/unions.mdx | 10 + examples/query.tsx | 2 +- examples/tests/balance.test.ts | 6 +- examples/tests/balances.test.ts | 6 +- examples/tests/block.test.ts | 6 +- examples/tests/contract-balance.test.ts | 6 +- examples/tests/contract-balances.test.ts | 6 +- examples/tests/latest-blocks.test.ts | 6 +- examples/tests/latest-transactions.test.ts | 6 +- examples/tests/messages.test.ts | 6 +- examples/tests/transactions-by-owner.test.ts | 6 +- src/components/CodeExamples.tsx | 4 +- 16 files changed, 348 insertions(+), 88 deletions(-) diff --git a/docs/overview.mdx b/docs/overview.mdx index 4ba77f2..68a4ee9 100644 --- a/docs/overview.mdx +++ b/docs/overview.mdx @@ -14,10 +14,16 @@ The playground is an interactive and graphical IDE that includes a reference for You can test out the Fuel GraphQL API playground here: +Beta-5: +https://beta-5.fuel.network/playground + Beta-4: https://beta-4.fuel.network/playground ## API Endpoint +Beta-5: +https://beta-5.fuel.network/graphql + Beta-4: https://beta-4.fuel.network/graphql diff --git a/docs/querying-from-a-dapp.mdx b/docs/querying-from-a-dapp.mdx index 8954839..a69cc6b 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-4.fuel.network/graphql', { + let response = await fetch('https://beta-5.fuel.network/graphql', { 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-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); @@ -66,7 +66,7 @@ npm install urql graphql import { Client, cacheExchange, fetchExchange } from 'urql'; const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); diff --git a/docs/reference/mutations.mdx b/docs/reference/mutations.mdx index 609e1bb..87f17c2 100644 --- a/docs/reference/mutations.mdx +++ b/docs/reference/mutations.mdx @@ -3,8 +3,82 @@ title: Mutations category: Reference --- +{/* TODO: Finish this mutation */} + # Mutations +## `startSession` + +### `startSession` `args` + +`id: ID!` + +returns `Boolean!` + +## `endSession` + +### `endSession` `args` + +`id: ID!` + +returns `Boolean!` + +## `reset` + +### `reset` `args` + +`id: ID!` + +returns `Boolean!` + +## `execute` + +### `execute` `args` + +`id: ID!` + +`op: String!` + +returns `Boolean!` + +## `setSingleStepping` + +### `setSingleStepping` `args` + +`id: ID!` + +`enable: boolean` + +returns `Boolean!` + +## `setBreakpoint` + +### `setBreakpoint` `args` + +`id: ID!` + +`breakpoint`: [`Breakpoint!`](/docs/reference/objects/#breakpoint) + +returns `Boolean!` + +## `startTx` + +### `startTx` `args` + +`id: ID!` + +`txJson: String!` + +returns `RunResult!` + +## `continueTx` + +### `continueTx` `args` + +`id: ID!` + +returns `RunResult!` + ## `dryRun` A mutation that spins up a new temporary node from the current state and emulates a given transaction. diff --git a/docs/reference/objects.mdx b/docs/reference/objects.mdx index 7bf7b76..492d583 100644 --- a/docs/reference/objects.mdx +++ b/docs/reference/objects.mdx @@ -55,6 +55,18 @@ The type of consensus used. An array of transactions included in the block. +## `Breakpoint` + +A breakpoint during debugging + +`contract`: [`ContractId!`](/docs/reference/scalars/#contractid) + +The contract address. + +`pc`: [`U64`](/docs/reference/scalars/#u64) + +The value of the program counter register `$pc`, which is the memory address of the current instruction. + ## `ChainInfo` Information about the base chain. At a very high level `chainInfo` helps you understand what Fuel chain you're connected to and the different parameters of this chain. @@ -63,24 +75,28 @@ 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-4 +The human-readable string name of the chain. i.e. beta-5 `latestBlock`: [`Block!`](#block) The most recently created block. -`baseChainHeight`: [`U32!`](/docs/reference/scalars/#u32) +> `baseChainHeight`: [`U32!`](/docs/reference/scalars/#u32) _(beta-4 only)_ -Returns 0 (in development mode, this will change). This should return the height of the chain at start. +> Returns 0 (in development mode, this will change). This should return the height of the chain at start. -`peerCount: Int!` +> `peerCount: Int!` _(beta-4 only)_ -The number of nodes that node is peered with. +> The number of nodes that node is peered with. `consensusParameters`: [`ConsensusParameters!`](#consensusparameters) The consensus parameters used to validate blocks. +`daHeight`: [`U64!`](/docs/reference/scalars/#u64) + +The height of the base chain via relayer (i.e. Ethereum or DA) + `gasCosts`: [`GasCosts!`](#gascosts) The gas cost of each opcode. @@ -175,59 +191,85 @@ The consensus parameters used for validating blocks. **fields:** -`contractMaxSize`: [`U64!`](/docs/reference/scalars/#u64) +{/* TODO NEW */} -The maximum contract size, in bytes. +`txParams`: [`TxParameters!`](#TxParameters) -`maxInputs`: [`U64!`](/docs/reference/scalars/#u64) +The allowed parameters of transactions -The maximum number of inputs. +`predicateParams`: [`PredicateParameters!`](#PredicateParameters) -`maxOutputs`: [`U64!`](/docs/reference/scalars/#u64) +The allowed parameters of predicates -The maximum number of outputs. +`scriptParams`: [`ScriptParameters!`](#ScriptParameters) -`maxWitnesses`: [`U64!`](/docs/reference/scalars/#u64) +The allowed parameters of scripts -The maximum number of witnesses. +`contractParams`: [`ContractParameters!`](#ContractParameters) -`maxGasPerTx`: [`U64!`](/docs/reference/scalars/#u64) +The allowed parameters of contracts -The maximum gas per transaction. +`feeParams`: [`FeeParameters!`](#FeeParameters) -`maxScriptLength`: [`U64!`](/docs/reference/scalars/#u64) +The allowed parameters of fees -The maximum length of a script, in instructions. +`baseAssetId`: [`AssetId!`](/docs/reference/scalars/#assetid) -`maxGasPerPredicate`: [`U64!`](/docs/reference/scalars/#u64) +The asset id of the "base" asset used for gas fees. -The maximum gas per predicate transaction. +> `contractMaxSize`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -`maxScriptDataLength`: [`U64!`](/docs/reference/scalars/#u64) +> The maximum contract size, in bytes. -The maximum length of script data, in bytes. +> `maxInputs`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -`maxStorageSlots`: [`U64!`](/docs/reference/scalars/#u64) +> The maximum number of inputs. -The maximum number of initial storage slots. +> `maxOutputs`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -`maxPredicateLength`: [`U64!`](/docs/reference/scalars/#u64) +> The maximum number of outputs. -The maximum length of a predicate, in instructions. +> `maxWitnesses`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -`maxPredicateDataLength`: [`U64!`](/docs/reference/scalars/#u64) +> The maximum number of witnesses. -The maximum length of predicate data, in bytes. +> `maxGasPerTx`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -`gasPriceFactor`: [`U64!`](/docs/reference/scalars/#u64) +> The maximum gas per transaction. -A factor to convert between gas and the transaction assets value. +> `maxScriptLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -`gasPerByte`: [`U64!`](/docs/reference/scalars/#u64) +> The maximum length of a script, in instructions. + +> `maxGasPerPredicate`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ + +> The maximum gas per predicate transaction. + +> `maxScriptDataLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ + +> The maximum length of script data, in bytes. + +> `maxStorageSlots`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ + +> The maximum number of initial storage slots. + +> `maxPredicateLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ + +> The maximum length of a predicate, in instructions. + +> `maxPredicateDataLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ + +> The maximum length of predicate data, in bytes. + +> `gasPriceFactor`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -A fixed ratio linking metered bytes to a gas price. +> A factor to convert between gas and the transaction assets value. -`maxMessageDataLength`: [`U64!`](/docs/reference/scalars/#u64) +> `gasPerByte`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ + +> A fixed ratio linking metered bytes to a gas price. + +> `maxMessageDataLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ The maximum length of message data, in bytes. @@ -235,6 +277,10 @@ The maximum length of message data, in bytes. A unique identifier for the chain. +`gasCosts`: [`GasCosts!`](#gascosts) + +The gas cost of each opcode. + ## `Contract` An object representing a deployed contract. @@ -313,7 +359,19 @@ The root of amount of coins owned by contract after transaction execution. The state root of contract after transaction execution. -## `DependentCost` +## `ContractParameters` + +An object containing information about a contract + +`contractMaxSize`: [`U64!`](/docs/reference/scalars/#u64) + +Maximum size of a contract in bytes + +`maxStorageSlots`: [`U64!`](/docs/reference/scalars/#u64) + +Maximum number of storage slots + +## `DependentCost`_(beta-4 only)_ Contains the dependent cost of opcodes. @@ -347,6 +405,10 @@ The status type of a transaction that has failed. **fields:** +`transactionId`: [`TransactionId!`](/docs/reference/scalars/#transactionid) + +A unique transaction id. + `block`: [`Block!`](#block) The block number for the failed transaction. @@ -363,6 +425,16 @@ The reason why the transaction failed. The state of the program execution. +## `FeeParameters` + +`gasPriceFactor`: [`U64!`](/docs/reference/scalars/#u64) + +The dynamic adjustment of gas costs + +`gasPerByte`: [`U64!`](/docs/reference/scalars/#u64) + +The gas cost per byte + ## `GasCosts` The breakdown of the gas costs of each opcode. @@ -513,9 +585,9 @@ The gas cost of using the `$jnef` control flow opcode. The gas cost of using the `$jneb` control flow opcode. -`k256`: [`U64!`](/docs/reference/scalars/#u64) +> `k256`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -The gas cost of using the `$k256` cryptographic opcode. +> The gas cost of using the `$k256` cryptographic opcode. `lb`: [`U64!`](/docs/reference/scalars/#u64) @@ -533,9 +605,9 @@ The gas cost of using the `$lt` ALU opcode. The gas cost of using the `$lw` memory opcode. -`mcpi`: [`U64!`](/docs/reference/scalars/#u64) +> `mcpi`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -The gas cost of using the `$mcpi` memory opcode. +> The gas cost of using the `$mcpi` memory opcode. `mint`: [`U64!`](/docs/reference/scalars/#u64) @@ -593,6 +665,22 @@ The gas cost of using the `$or` ALU opcode. The gas cost of using the `$ori` ALU opcode. +`poph`: [`U64!`](/docs/reference/scalars/#u64) + +The gas cost of using the `$poph` opcode. + +`popl`: [`U64!`](/docs/reference/scalars/#u64) + +The gas cost of using the `$popl` opcode. + +`pshh`: [`U64!`](/docs/reference/scalars/#u64) + +The gas cost of using the `$pshh` opcode. + +`pshl`: [`U64!`](/docs/reference/scalars/#u64) + +The gas cost of using the `$pshl` opcode. + `ret`: [`U64!`](/docs/reference/scalars/#u64) The gas cost of using the `$ret` opcode. @@ -601,17 +689,17 @@ The gas cost of using the `$ret` opcode. The gas cost of using the `$rvrt` contract opcode. -`s256`: [`U64!`](/docs/reference/scalars/#u64) +> `s256`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -The gas cost of using the `$s256` cryptographic opcode. +> The gas cost of using the `$s256` cryptographic opcode. `sb`: [`U64!`](/docs/reference/scalars/#u64) The gas cost of using the `$sb` memory opcode. -`scwq`: [`U64!`](/docs/reference/scalars/#u64) +> `scwq`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -The gas cost of using the `$scwq` contract opcode. +> The gas cost of using the `$scwq` contract opcode. `sll`: [`U64!`](/docs/reference/scalars/#u64) @@ -649,9 +737,9 @@ The gas cost of using the `$sw` memory opcode. The gas cost of using the `$sww` contract opcode. -`swwq`: [`U64!`](/docs/reference/scalars/#u64) +> `swwq`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ -The gas cost of using the `$swwq` contract opcode. +> The gas cost of using the `$swwq` contract opcode. `time`: [`U64!`](/docs/reference/scalars/#u64) @@ -729,54 +817,90 @@ The gas cost of using the `$xor` ALU opcode. The gas cost of using the `$xori` ALU opcode. -`call`: [`DependentCost!`](#dependentcost) +`call`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$call` contract opcode. -`ccp`: [`DependentCost!`](#dependentcost) +`ccp`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$ccp` contract opcode. -`csiz`: [`DependentCost!`](#dependentcost) +`csiz`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$csiz` contract opcode. -`ldc`: [`DependentCost!`](#dependentcost) +`k256`: [`DependentCost!`](/docs/reference/unions/#dependentcost) + +The `dependent` gas cost of using the `$k256` cryptographic opcode. + +`ldc`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$ldc` contract opcode. -`logd`: [`DependentCost!`](#dependentcost) +`logd`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$logd` contract opcode. -`mcl`: [`DependentCost!`](#dependentcost) +`mcl`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$mcl` memory opcode. -`mcli`: [`DependentCost!`](#dependentcost) +`mcli`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$mcli` memory opcode. -`mcp`: [`DependentCost!`](#dependentcost) +`mcp`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$mcp` memory opcode. -`meq`: [`DependentCost!`](#dependentcost) +`mcpi`: [`DependentCost`](/docs/reference/unions/#dependentcost) + +The `dependent` gas cost of using the `$mcpi` memory opcode. + +`meq`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$meq` memory opcode. -`retd`: [`DependentCost!`](#dependentcost) +`retd`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$retd` contract opcode. -`smo`: [`DependentCost!`](#dependentcost) +`s256`: [`DependentCost`](/docs/reference/unions/#dependentcost) + +The `dependent` gas cost of using the `$mcpi` cryptographic opcode. + +`scwq`: [`DependentCost`](/docs/reference/unions/#dependentcost) + +The `dependent` gas cost of using the `$scwq` cryptographic opcode. + +`smo`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$smo` contract opcode. -`srwq`: [`DependentCost!`](#dependentcost) +`srwq`: [`DependentCost!`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$srwq` contract opcode. +`swwq`: [`DependentCost!`](/docs/reference/unions/#dependentcost) + +The `dependent` gas cost of using the `$swwq` contract opcode. + +`swwq`: [`DependentCost!`](/docs/reference/unions/#dependentcost) + +The `dependent` gas cost of using the `$swwq` contract opcode. + +`contractRoot`: [`DependentCost!`](/docs/reference/unions/#dependentcost) + +The `dependent` gas cost calculating the `contractRoot` + +`stateRoot`: [`DependentCost!`](/docs/reference/unions/#dependentcost) + +The `dependent` gas cost calculating the `stateRoot` + +`newStoragePerByte`: [`U64!`](/docs/reference/scalars/#u64) + +The gas cost of storage per byte + ## `Genesis` The genesis consensus type. @@ -799,6 +923,20 @@ The binary Merkle tree root of state, balances, and the contracts code hash of e The binary merkle tree root of all genesis messages. +## `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 + +**fields:** + +`base`: [`U64!`](/docs/reference/scalars/#u64) + +The minimum gas that this operation can cost + +`gasPerUnit`: [`U64!`](/docs/reference/scalars/#u64) + +The gas is required to process a single unit + ## `Header` The header contains metadata about a certain block. @@ -955,6 +1093,20 @@ The predicate bytecode. The predicate input parameters. +## `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 + +**fields:** + +`base`: [`U64!`](/docs/reference/scalars/#u64) + +The minimum gas that this operation can cost + +`unitsPerGas`: [`U64!`](/docs/reference/scalars/#u64) + +The units that can be processed with a single gas + ## `MerkleProof` Information about a merkle proof. @@ -1105,6 +1257,24 @@ The maximum number of connected UTXOs allowed, excluding contracts. The node version. +`peers: [`PeerInfo!`](#peerinfo)!` + +The information about the node's peers. + +## `OutputBreakpoint` + +A breakpoint during debugging + +`contract`: [`ContractId!`](/docs/reference/scalars/#contractid) + +The contract address. + +`pc`: [`U64`](/docs/reference/scalars/#u64) + +The value of the program counter register `$pc`, which is the memory address of the current instruction. + +## `peer` + ## `PoAConsensus` The proof-of-authority (PoA) consensus type. diff --git a/docs/reference/unions.mdx b/docs/reference/unions.mdx index 467618a..25889f2 100644 --- a/docs/reference/unions.mdx +++ b/docs/reference/unions.mdx @@ -26,6 +26,16 @@ The type of consensus mechanism used to validate a block. [`PoAConsensus`](/docs/reference/objects/#poaconsensus): PoA consensus +## `DependentCost` + +Contains the dependent cost of opcodes. + +**Types:** + +[`LightOperation`](/docs/reference/objects/#lightoperation): Operations that can process many units with 1 gas + +[`HeavyOperation`](/docs/reference/objects/#heavyoperation): Operations that require more than 1 gas to process a single unit + ## `Input` An input type for a transaction. diff --git a/examples/query.tsx b/examples/query.tsx index 144677f..4707913 100644 --- a/examples/query.tsx +++ b/examples/query.tsx @@ -15,7 +15,7 @@ export function Query(props: QueryProps) { function runQuery() { setLoading(true); - fetch('https://beta-4.fuel.network/graphql', { + fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/examples/tests/balance.test.ts b/examples/tests/balance.test.ts index eda9f48..050049c 100644 --- a/examples/tests/balance.test.ts +++ b/examples/tests/balance.test.ts @@ -3,12 +3,12 @@ import { Client, cacheExchange, fetchExchange } from 'urql'; import 'isomorphic-fetch'; const apolloClient = new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); @@ -30,7 +30,7 @@ describe('Balance', () => { }; const getBalance = async () => { - const response = await fetch('https://beta-4.fuel.network/graphql', { + const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/examples/tests/balances.test.ts b/examples/tests/balances.test.ts index b187814..502de0f 100644 --- a/examples/tests/balances.test.ts +++ b/examples/tests/balances.test.ts @@ -3,12 +3,12 @@ import { Client, cacheExchange, fetchExchange } from 'urql'; import 'isomorphic-fetch'; const apolloClient = new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); @@ -31,7 +31,7 @@ describe('Balances', () => { }; const getBalances = async () => { - const response = await fetch('https://beta-4.fuel.network/graphql', { + const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/examples/tests/block.test.ts b/examples/tests/block.test.ts index b09f365..f00902b 100644 --- a/examples/tests/block.test.ts +++ b/examples/tests/block.test.ts @@ -3,12 +3,12 @@ import { Client, cacheExchange, fetchExchange } from 'urql'; import 'isomorphic-fetch'; const apolloClient = new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); @@ -24,7 +24,7 @@ describe('Block Info', () => { const args = { height: '3412' }; const getBlock = async () => { - const response = await fetch('https://beta-4.fuel.network/graphql', { + const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/examples/tests/contract-balance.test.ts b/examples/tests/contract-balance.test.ts index c8fec60..4a50bc6 100644 --- a/examples/tests/contract-balance.test.ts +++ b/examples/tests/contract-balance.test.ts @@ -3,12 +3,12 @@ import { Client, cacheExchange, fetchExchange } from 'urql'; import 'isomorphic-fetch'; const apolloClient = new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); @@ -30,7 +30,7 @@ describe('Contract Balance', () => { }; const getContractBalance = async () => { - const response = await fetch('https://beta-4.fuel.network/graphql', { + const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/examples/tests/contract-balances.test.ts b/examples/tests/contract-balances.test.ts index 9eb0875..554d4c8 100644 --- a/examples/tests/contract-balances.test.ts +++ b/examples/tests/contract-balances.test.ts @@ -3,12 +3,12 @@ import { Client, cacheExchange, fetchExchange } from 'urql'; import 'isomorphic-fetch'; const apolloClient = new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); @@ -32,7 +32,7 @@ describe('Contract balances', () => { }; const getContractBalances = async () => { - const response = await fetch('https://beta-4.fuel.network/graphql', { + const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/examples/tests/latest-blocks.test.ts b/examples/tests/latest-blocks.test.ts index 2656f1a..3c0a698 100644 --- a/examples/tests/latest-blocks.test.ts +++ b/examples/tests/latest-blocks.test.ts @@ -3,12 +3,12 @@ import { Client, cacheExchange, fetchExchange } from 'urql'; import 'isomorphic-fetch'; const apolloClient = new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); @@ -78,7 +78,7 @@ describe('Latest blocks', () => { }`; const getLatestBlocks = async () => { - const response = await fetch('https://beta-4.fuel.network/graphql', { + const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/examples/tests/latest-transactions.test.ts b/examples/tests/latest-transactions.test.ts index 7eda540..290b946 100644 --- a/examples/tests/latest-transactions.test.ts +++ b/examples/tests/latest-transactions.test.ts @@ -3,12 +3,12 @@ import { Client, cacheExchange, fetchExchange } from 'urql'; import 'isomorphic-fetch'; const apolloClient = new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); @@ -83,7 +83,7 @@ describe('Latest transactions', () => { }`; const getLatestTransactions = async () => { - const response = await fetch('https://beta-4.fuel.network/graphql', { + const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/examples/tests/messages.test.ts b/examples/tests/messages.test.ts index 02ebd72..8a411a9 100644 --- a/examples/tests/messages.test.ts +++ b/examples/tests/messages.test.ts @@ -3,12 +3,12 @@ import { Client, cacheExchange, fetchExchange } from 'urql'; import 'isomorphic-fetch'; const apolloClient = new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); @@ -34,7 +34,7 @@ describe('Messages', () => { }; const getMessages = async () => { - const response = await fetch('https://beta-4.fuel.network/graphql', { + const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/examples/tests/transactions-by-owner.test.ts b/examples/tests/transactions-by-owner.test.ts index 1e4dc0d..0899292 100644 --- a/examples/tests/transactions-by-owner.test.ts +++ b/examples/tests/transactions-by-owner.test.ts @@ -3,12 +3,12 @@ import { Client, cacheExchange, fetchExchange } from 'urql'; import 'isomorphic-fetch'; const apolloClient = new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', cache: new InMemoryCache(), }); const urqlClient = new Client({ - url: 'https://beta-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); @@ -88,7 +88,7 @@ describe('Transactions by owner', () => { }; const getTransactions = async () => { - const response = await fetch('https://beta-4.fuel.network/graphql', { + const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/components/CodeExamples.tsx b/src/components/CodeExamples.tsx index 0045041..e9793f8 100644 --- a/src/components/CodeExamples.tsx +++ b/src/components/CodeExamples.tsx @@ -58,7 +58,7 @@ export function CodeExamples({ const apolloImport = `import { ApolloClient, InMemoryCache, gql } from '@apollo/client'; const apolloClient= new ApolloClient({ - uri: 'https://beta-4.fuel.network/graphql', + uri: 'https://beta-5.fuel.network/graphql', 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-4.fuel.network/graphql', + url: 'https://beta-5.fuel.network/graphql', exchanges: [cacheExchange, fetchExchange], }); From ffe84678679fcb9d2b745bf01ab2b30f841bc1da Mon Sep 17 00:00:00 2001 From: Call Delegation Date: Wed, 27 Dec 2023 17:37:48 -0500 Subject: [PATCH 02/13] spellcheck --- spell-check-custom-words.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spell-check-custom-words.txt b/spell-check-custom-words.txt index b587e2b..854dd9f 100644 --- a/spell-check-custom-words.txt +++ b/spell-check-custom-words.txt @@ -72,4 +72,6 @@ merkle Merkle mempool EOA -args \ No newline at end of file +args +breakpoint +PeerInfo \ No newline at end of file From 9d8c95054b7c5d129111b05b6cbc0d342c6c93e9 Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:52:29 -0700 Subject: [PATCH 03/13] fix audit --- package-lock.json | 167 ++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 82 insertions(+), 87 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6368026..ba4f43c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,7 @@ "hastscript": "^7.2.0", "isomorphic-fetch": "^3.0.0", "markdownlint-cli": "^0.37.0", - "next": "13.4.19", + "next": "^13.5.6", "next-mdx-remote": "^4.4.1", "node-html-markdown": "^1.3.0", "plyr-react": "^5.3.0", @@ -3132,9 +3132,9 @@ } }, "node_modules/@next/env": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.19.tgz", - "integrity": "sha512-FsAT5x0jF2kkhNkKkukhsyYOrRqtSxrEhfliniIq0bwWbuXLgyt3Gv0Ml+b91XwjwArmuP7NxCiGd++GGKdNMQ==" + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/env/-/env-13.5.6.tgz", + "integrity": "sha512-Yac/bV5sBGkkEXmAX5FWPS9Mmo2rthrOPRQQNfycJPkjUAUclomCPH7QFVCDQ4Mp2k2K1SSM6m0zrxYrOwtFQw==" }, "node_modules/@next/eslint-plugin-next": { "version": "13.5.6", @@ -3145,9 +3145,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.19.tgz", - "integrity": "sha512-vv1qrjXeGbuF2mOkhkdxMDtv9np7W4mcBtaDnHU+yJG+bBwa6rYsYSCI/9Xm5+TuF5SbZbrWO6G1NfTh1TMjvQ==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.5.6.tgz", + "integrity": "sha512-5nvXMzKtZfvcu4BhtV0KH1oGv4XEW+B+jOfmBdpFI3C7FrB/MfujRpWYSBBO64+qbW8pkZiSyQv9eiwnn5VIQA==", "cpu": [ "arm64" ], @@ -3160,9 +3160,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.4.19.tgz", - "integrity": "sha512-jyzO6wwYhx6F+7gD8ddZfuqO4TtpJdw3wyOduR4fxTUCm3aLw7YmHGYNjS0xRSYGAkLpBkH1E0RcelyId6lNsw==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.6.tgz", + "integrity": "sha512-6cgBfxg98oOCSr4BckWjLLgiVwlL3vlLj8hXg2b+nDgm4bC/qVXXLfpLB9FHdoDu4057hzywbxKvmYGmi7yUzA==", "cpu": [ "x64" ], @@ -3175,9 +3175,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.4.19.tgz", - "integrity": "sha512-vdlnIlaAEh6H+G6HrKZB9c2zJKnpPVKnA6LBwjwT2BTjxI7e0Hx30+FoWCgi50e+YO49p6oPOtesP9mXDRiiUg==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.6.tgz", + "integrity": "sha512-txagBbj1e1w47YQjcKgSU4rRVQ7uF29YpnlHV5xuVUsgCUf2FmyfJ3CPjZUvpIeXCJAoMCFAoGnbtX86BK7+sg==", "cpu": [ "arm64" ], @@ -3190,9 +3190,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.4.19.tgz", - "integrity": "sha512-aU0HkH2XPgxqrbNRBFb3si9Ahu/CpaR5RPmN2s9GiM9qJCiBBlZtRTiEca+DC+xRPyCThTtWYgxjWHgU7ZkyvA==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.6.tgz", + "integrity": "sha512-cGd+H8amifT86ZldVJtAKDxUqeFyLWW+v2NlBULnLAdWsiuuN8TuhVBt8ZNpCqcAuoruoSWynvMWixTFcroq+Q==", "cpu": [ "arm64" ], @@ -3205,9 +3205,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.4.19.tgz", - "integrity": "sha512-htwOEagMa/CXNykFFeAHHvMJeqZfNQEoQvHfsA4wgg5QqGNqD5soeCer4oGlCol6NGUxknrQO6VEustcv+Md+g==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.6.tgz", + "integrity": "sha512-Mc2b4xiIWKXIhBy2NBTwOxGD3nHLmq4keFk+d4/WL5fMsB8XdJRdtUlL87SqVCTSaf1BRuQQf1HvXZcy+rq3Nw==", "cpu": [ "x64" ], @@ -3220,9 +3220,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.4.19.tgz", - "integrity": "sha512-4Gj4vvtbK1JH8ApWTT214b3GwUh9EKKQjY41hH/t+u55Knxi/0wesMzwQRhppK6Ddalhu0TEttbiJ+wRcoEj5Q==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.6.tgz", + "integrity": "sha512-CFHvP9Qz98NruJiUnCe61O6GveKKHpJLloXbDSWRhqhkJdZD2zU5hG+gtVJR//tyW897izuHpM6Gtf6+sNgJPQ==", "cpu": [ "x64" ], @@ -3235,9 +3235,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.4.19.tgz", - "integrity": "sha512-bUfDevQK4NsIAHXs3/JNgnvEY+LRyneDN788W2NYiRIIzmILjba7LaQTfihuFawZDhRtkYCv3JDC3B4TwnmRJw==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.6.tgz", + "integrity": "sha512-aFv1ejfkbS7PUa1qVPwzDHjQWQtknzAZWGTKYIAaS4NMtBlk3VyA6AYn593pqNanlicewqyl2jUhQAaFV/qXsg==", "cpu": [ "arm64" ], @@ -3250,9 +3250,9 @@ } }, "node_modules/@next/swc-win32-ia32-msvc": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.4.19.tgz", - "integrity": "sha512-Y5kikILFAr81LYIFaw6j/NrOtmiM4Sf3GtOc0pn50ez2GCkr+oejYuKGcwAwq3jiTKuzF6OF4iT2INPoxRycEA==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.6.tgz", + "integrity": "sha512-XqqpHgEIlBHvzwG8sp/JXMFkLAfGLqkbVsyN+/Ih1mR8INb6YCc2x/Mbwi6hsAgUnqQztz8cvEbHJUbSl7RHDg==", "cpu": [ "ia32" ], @@ -3265,9 +3265,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.4.19.tgz", - "integrity": "sha512-YzA78jBDXMYiINdPdJJwGgPNT3YqBNNGhsthsDoWHL9p24tEJn9ViQf/ZqTbwSpX/RrkPupLfuuTH2sf73JBAw==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.6.tgz", + "integrity": "sha512-Cqfe1YmOS7k+5mGu92nl5ULkzpKuxJrP3+4AEuPmrpFZ3BHxTY3TnHmU1On3bFmFFs6FbTcdF58CCUProGpIGQ==", "cpu": [ "x64" ], @@ -3538,14 +3538,14 @@ "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" }, "node_modules/@pm2/js-api": { - "version": "0.6.7", - "resolved": "https://registry.npmjs.org/@pm2/js-api/-/js-api-0.6.7.tgz", - "integrity": "sha512-jiJUhbdsK+5C4zhPZNnyA3wRI01dEc6a2GhcQ9qI38DyIk+S+C8iC3fGjcjUbt/viLYKPjlAaE+hcT2/JMQPXw==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@pm2/js-api/-/js-api-0.8.0.tgz", + "integrity": "sha512-nmWzrA/BQZik3VBz+npRcNIu01kdBhWL0mxKmP1ciF/gTcujPTQqt027N9fc1pK9ERM8RipFhymw7RcmCyOEYA==", "dependencies": { "async": "^2.6.3", - "axios": "^0.21.0", "debug": "~4.3.1", "eventemitter2": "^6.3.1", + "extrareqp2": "^1.0.0", "ws": "^7.0.0" }, "engines": { @@ -7760,14 +7760,6 @@ "node": ">=4" } }, - "node_modules/axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "dependencies": { - "follow-redirects": "^1.14.0" - } - }, "node_modules/axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -10194,6 +10186,14 @@ "url": "https://github.com/sponsors/jaydenseric" } }, + "node_modules/extrareqp2": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/extrareqp2/-/extrareqp2-1.0.0.tgz", + "integrity": "sha512-Gum0g1QYb6wpPJCVypWP3bbIuaibcFiJcpuPM10YSXp/tzqi84x9PJageob+eN4xVRIOto4wjSGNLyMD54D2xA==", + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -10342,9 +10342,9 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==" }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", "funding": [ { "type": "individual", @@ -15166,9 +15166,9 @@ "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" }, "node_modules/nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", "funding": [ { "type": "github", @@ -15231,35 +15231,34 @@ } }, "node_modules/next": { - "version": "13.4.19", - "resolved": "https://registry.npmjs.org/next/-/next-13.4.19.tgz", - "integrity": "sha512-HuPSzzAbJ1T4BD8e0bs6B9C1kWQ6gv8ykZoRWs5AQoiIuqbGHHdQO7Ljuvg05Q0Z24E2ABozHe6FxDvI6HfyAw==", + "version": "13.5.6", + "resolved": "https://registry.npmjs.org/next/-/next-13.5.6.tgz", + "integrity": "sha512-Y2wTcTbO4WwEsVb4A8VSnOsG1I9ok+h74q0ZdxkwM3EODqrs4pasq7O0iUxbcS9VtWMicG7f3+HAj0r1+NtKSw==", "dependencies": { - "@next/env": "13.4.19", - "@swc/helpers": "0.5.1", + "@next/env": "13.5.6", + "@swc/helpers": "0.5.2", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001406", - "postcss": "8.4.14", + "postcss": "8.4.31", "styled-jsx": "5.1.1", - "watchpack": "2.4.0", - "zod": "3.21.4" + "watchpack": "2.4.0" }, "bin": { "next": "dist/bin/next" }, "engines": { - "node": ">=16.8.0" + "node": ">=16.14.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "13.4.19", - "@next/swc-darwin-x64": "13.4.19", - "@next/swc-linux-arm64-gnu": "13.4.19", - "@next/swc-linux-arm64-musl": "13.4.19", - "@next/swc-linux-x64-gnu": "13.4.19", - "@next/swc-linux-x64-musl": "13.4.19", - "@next/swc-win32-arm64-msvc": "13.4.19", - "@next/swc-win32-ia32-msvc": "13.4.19", - "@next/swc-win32-x64-msvc": "13.4.19" + "@next/swc-darwin-arm64": "13.5.6", + "@next/swc-darwin-x64": "13.5.6", + "@next/swc-linux-arm64-gnu": "13.5.6", + "@next/swc-linux-arm64-musl": "13.5.6", + "@next/swc-linux-x64-gnu": "13.5.6", + "@next/swc-linux-x64-musl": "13.5.6", + "@next/swc-win32-arm64-msvc": "13.5.6", + "@next/swc-win32-ia32-msvc": "13.5.6", + "@next/swc-win32-x64-msvc": "13.5.6" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", @@ -15311,21 +15310,13 @@ } }, "node_modules/next/node_modules/@swc/helpers": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.1.tgz", - "integrity": "sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.2.tgz", + "integrity": "sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==", "dependencies": { "tslib": "^2.4.0" } }, - "node_modules/next/node_modules/zod": { - "version": "3.21.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz", - "integrity": "sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", @@ -16240,13 +16231,13 @@ } }, "node_modules/pm2": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/pm2/-/pm2-5.3.0.tgz", - "integrity": "sha512-xscmQiAAf6ArVmKhjKTeeN8+Td7ZKnuZFFPw1DGkdFPR/0Iyx+m+1+OpCdf9+HQopX3VPc9/wqPQHqVOfHum9w==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/pm2/-/pm2-5.3.1.tgz", + "integrity": "sha512-DLVQHpSR1EegaTaRH3KbRXxpPVaqYwAp3uHSCtCsS++LSErvk07WSxuUnntFblBRqNU/w2KQyqs12mSq5wurkg==", "dependencies": { "@pm2/agent": "~2.0.0", "@pm2/io": "~5.0.0", - "@pm2/js-api": "~0.6.7", + "@pm2/js-api": "~0.8.0", "@pm2/pm2-version-check": "latest", "async": "~3.2.0", "blessed": "0.1.81", @@ -16437,9 +16428,9 @@ } }, "node_modules/postcss": { - "version": "8.4.14", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", - "integrity": "sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==", + "version": "8.4.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", + "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "funding": [ { "type": "opencollective", @@ -16448,10 +16439,14 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], "dependencies": { - "nanoid": "^3.3.4", + "nanoid": "^3.3.6", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, diff --git a/package.json b/package.json index 9dbe54c..afcb269 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "hastscript": "^7.2.0", "isomorphic-fetch": "^3.0.0", "markdownlint-cli": "^0.37.0", - "next": "13.4.19", + "next": "^13.5.6", "next-mdx-remote": "^4.4.1", "node-html-markdown": "^1.3.0", "plyr-react": "^5.3.0", From 1c872d466e9356101ca438410c30a21ff276b32b Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Fri, 26 Jan 2024 07:47:13 -0700 Subject: [PATCH 04/13] draft coverage test --- docs/overview.mdx | 10 +- docs/reference/enums.mdx | 23 ++ docs/reference/mutations.mdx | 6 +- docs/reference/objects.mdx | 266 +++++++++++-------- docs/reference/queries.mdx | 10 + docs/reference/scalars.mdx | 4 + docs/reference/subscriptions.mdx | 2 +- examples/tests/transactions-by-owner.test.ts | 6 +- scripts/coverage/index.mjs | 112 ++++++++ scripts/coverage/queries.mjs | 239 +++++++++++++++++ scripts/coverage/utils.mjs | 146 ++++++++++ 11 files changed, 695 insertions(+), 129 deletions(-) create mode 100644 scripts/coverage/index.mjs create mode 100644 scripts/coverage/queries.mjs create mode 100644 scripts/coverage/utils.mjs diff --git a/docs/overview.mdx b/docs/overview.mdx index 68a4ee9..851ce3b 100644 --- a/docs/overview.mdx +++ b/docs/overview.mdx @@ -14,16 +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: -Beta-5: https://beta-5.fuel.network/playground -Beta-4: -https://beta-4.fuel.network/playground +## RPC Endpoint -## API Endpoint - -Beta-5: https://beta-5.fuel.network/graphql - -Beta-4: -https://beta-4.fuel.network/graphql diff --git a/docs/reference/enums.mdx b/docs/reference/enums.mdx index 7b05598..9b8346d 100644 --- a/docs/reference/enums.mdx +++ b/docs/reference/enums.mdx @@ -5,6 +5,19 @@ category: Reference # Enums +## `MessageState` + +The state of a message. + +`UNSPENT`: +The message is unspent. + +`SPENT`: +The message is spent. + +`NOT_FOUND`: +The message was not found. + ## `ReceiptType` The receipt type indicating what kind of transaction generated the receipt. @@ -60,3 +73,13 @@ Indicates the transaction returned some data. `REVERT`: Indicates the transaction reverted. + +## `RunState` + +The state of a [`RunResult`](/docs/reference/objects/#runresult). + +`COMPLETED`: +All breakpoints have been processed, and the program has terminated. + +`BREAKPOINT`: +The program stopped on a breakpoint. diff --git a/docs/reference/mutations.mdx b/docs/reference/mutations.mdx index 87f17c2..93f7f83 100644 --- a/docs/reference/mutations.mdx +++ b/docs/reference/mutations.mdx @@ -3,7 +3,7 @@ title: Mutations category: Reference --- -{/* TODO: Finish this mutation */} +{/*TODO: Finish this mutation*/} # Mutations @@ -37,7 +37,7 @@ returns `Boolean!` `id: ID!` -`op: String!` +`op: String!` returns `Boolean!` @@ -47,7 +47,7 @@ returns `Boolean!` `id: ID!` -`enable: boolean` +`enable: boolean` returns `Boolean!` diff --git a/docs/reference/objects.mdx b/docs/reference/objects.mdx index 492d583..d46b415 100644 --- a/docs/reference/objects.mdx +++ b/docs/reference/objects.mdx @@ -81,14 +81,6 @@ The human-readable string name of the chain. i.e. beta-5 The most recently created block. -> `baseChainHeight`: [`U32!`](/docs/reference/scalars/#u32) _(beta-4 only)_ - -> Returns 0 (in development mode, this will change). This should return the height of the chain at start. - -> `peerCount: Int!` _(beta-4 only)_ - -> The number of nodes that node is peered with. - `consensusParameters`: [`ConsensusParameters!`](#consensusparameters) The consensus parameters used to validate blocks. @@ -191,8 +183,6 @@ The consensus parameters used for validating blocks. **fields:** -{/* TODO NEW */} - `txParams`: [`TxParameters!`](#TxParameters) The allowed parameters of transactions @@ -205,11 +195,11 @@ The allowed parameters of predicates The allowed parameters of scripts -`contractParams`: [`ContractParameters!`](#ContractParameters) +`contractParams`: [`ContractParameters!`](#contractparameters) The allowed parameters of contracts -`feeParams`: [`FeeParameters!`](#FeeParameters) +`feeParams`: [`FeeParameters!`](#feeparameters) The allowed parameters of fees @@ -217,62 +207,6 @@ The allowed parameters of fees The asset id of the "base" asset used for gas fees. -> `contractMaxSize`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum contract size, in bytes. - -> `maxInputs`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum number of inputs. - -> `maxOutputs`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum number of outputs. - -> `maxWitnesses`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum number of witnesses. - -> `maxGasPerTx`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum gas per transaction. - -> `maxScriptLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum length of a script, in instructions. - -> `maxGasPerPredicate`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum gas per predicate transaction. - -> `maxScriptDataLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum length of script data, in bytes. - -> `maxStorageSlots`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum number of initial storage slots. - -> `maxPredicateLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum length of a predicate, in instructions. - -> `maxPredicateDataLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The maximum length of predicate data, in bytes. - -> `gasPriceFactor`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> A factor to convert between gas and the transaction assets value. - -> `gasPerByte`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> A fixed ratio linking metered bytes to a gas price. - -> `maxMessageDataLength`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -The maximum length of message data, in bytes. - `chainId`: [`U64!`](/docs/reference/scalars/#u64) A unique identifier for the chain. @@ -369,21 +303,7 @@ Maximum size of a contract in bytes `maxStorageSlots`: [`U64!`](/docs/reference/scalars/#u64) -Maximum number of storage slots - -## `DependentCost`_(beta-4 only)_ - -Contains the dependent cost of opcodes. - -**fields:** - -`base`: [`U64!`](/docs/reference/scalars/#u64) - -The base gas cost. - -`depPerUnit`: [`U64!`](/docs/reference/scalars/#u64) - -The dependent gas cost per unit. +Maximum number of storage slots ## `ExcludeInput` @@ -585,10 +505,6 @@ The gas cost of using the `$jnef` control flow opcode. The gas cost of using the `$jneb` control flow opcode. -> `k256`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The gas cost of using the `$k256` cryptographic opcode. - `lb`: [`U64!`](/docs/reference/scalars/#u64) The gas cost of using the `$lb` memory opcode. @@ -605,10 +521,6 @@ The gas cost of using the `$lt` ALU opcode. The gas cost of using the `$lw` memory opcode. -> `mcpi`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The gas cost of using the `$mcpi` memory opcode. - `mint`: [`U64!`](/docs/reference/scalars/#u64) The gas cost of using the `$mint` contract opcode. @@ -689,18 +601,10 @@ The gas cost of using the `$ret` opcode. The gas cost of using the `$rvrt` contract opcode. -> `s256`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The gas cost of using the `$s256` cryptographic opcode. - `sb`: [`U64!`](/docs/reference/scalars/#u64) The gas cost of using the `$sb` memory opcode. -> `scwq`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The gas cost of using the `$scwq` contract opcode. - `sll`: [`U64!`](/docs/reference/scalars/#u64) The gas cost of using the `$sll` ALU opcode. @@ -737,10 +641,6 @@ The gas cost of using the `$sw` memory opcode. The gas cost of using the `$sww` contract opcode. -> `swwq`: [`U64!`](/docs/reference/scalars/#u64) _(beta-4 only)_ - -> The gas cost of using the `$swwq` contract opcode. - `time`: [`U64!`](/docs/reference/scalars/#u64) The gas cost of using the `$time` contract opcode. @@ -853,7 +753,7 @@ The `dependent` gas cost of using the `$mcli` memory opcode. The `dependent` gas cost of using the `$mcp` memory opcode. -`mcpi`: [`DependentCost`](/docs/reference/unions/#dependentcost) +`mcpi`: [`DependentCost`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$mcpi` memory opcode. @@ -865,11 +765,11 @@ The `dependent` gas cost of using the `$meq` memory opcode. The `dependent` gas cost of using the `$retd` contract opcode. -`s256`: [`DependentCost`](/docs/reference/unions/#dependentcost) +`s256`: [`DependentCost`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$mcpi` cryptographic opcode. -`scwq`: [`DependentCost`](/docs/reference/unions/#dependentcost) +`scwq`: [`DependentCost`](/docs/reference/unions/#dependentcost) The `dependent` gas cost of using the `$scwq` cryptographic opcode. @@ -923,7 +823,7 @@ The binary Merkle tree root of state, balances, and the contracts code hash of e The binary merkle tree root of all genesis messages. -## `HeavyOperation` +## `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 @@ -1093,7 +993,7 @@ The predicate bytecode. The predicate input parameters. -## `LightOperation` +## `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 @@ -1227,17 +1127,27 @@ The amount sent in the message. The data from the message. +## `MessageStatus` + +The status type of a message. + +**fields:** + +`state`: [`MessageState`](/docs/reference/enums/#messagestate) + +The state of the message. + ## `NodeInfo` Information about a node. **fields:** -`utxoValidation: Boolean!` +`utxoValidation`: `Boolean!` Whether or not the node is using UTXO validation. -`vmBacktrace: Boolean!` +`vmBacktrace`: `Boolean!` Whether or not logging of backtraces from VM errors is enabled. @@ -1253,7 +1163,7 @@ The maximum number of transactions. The maximum number of connected UTXOs allowed, excluding contracts. -`nodeVersion: String!` +`nodeVersion`: `String!` The node version. @@ -1263,7 +1173,7 @@ The information about the node's peers. ## `OutputBreakpoint` -A breakpoint during debugging +A breakpoint during debugging. `contract`: [`ContractId!`](/docs/reference/scalars/#contractid) @@ -1273,7 +1183,35 @@ The contract address. The value of the program counter register `$pc`, which is the memory address of the current instruction. -## `peer` +## `PeerInfo` + +Information about a peer node. + +**fields:** + +`id`: `String!` + +The `libp2p` ID of the peer node. + +`addresses`: [`String!`]! + +The advertised addresses that can be used to connect to this peer node. + +`clientVersion`: `String` + +The self-reported version of the client the peer node is using. + +`blockHeight`: `U32` + +The last reported height of the peer node. + +`lastHeartbeatMs`: `U64!` + +The time of the last heartbeat from this peer node in unix epoch time milliseconds. + +`appScore`: `Float!` + +The internal Fuel peer-to-peer reputation of this peer node. ## `PoAConsensus` @@ -1299,6 +1237,50 @@ The type of return response for the transaction. The data returned from the transaction. +## `Policies` + +Information about the policies of a transaction. + +**fields:** + +`gasPrice`: [`U64`](/docs/reference/scalars/#u64) + +The price for each unit of gas consumed during the transaction execution. + +`witnessLimit`: [`U64`](/docs/reference/scalars/#u64) + +The limit of witnesses that can be included in the transaction. + +`maturity`: [`U32`](/docs/reference/scalars/#u32) + +The minimum block height that the transaction can be included at. + +`maxFee`: [`U64`](/docs/reference/scalars/#u64) + +The maximum fee allowed for the transaction to consume. + +## `PredicateParameters` + +The consensus parameters for a predicate. + +**fields:** + +`maxPredicateLength`: [`U64!`](/docs/reference/scalars/#u64) + +The maximum length of a predicate. + +`maxPredicateDataLength`: [`U64!`](/docs/reference/scalars/#u64) + +The maximum length of predicate data. + +`maxGasPerPredicate`: [`U64!`](/docs/reference/scalars/#u64) + +The maxiumum amount of gas allowed for a predicate. + +`maxMessageDataLength`: [`U64!`](/docs/reference/scalars/#u64) + +The maximum length of message data for a predicate. + ## `Receipt` An object representing all possible types of receipts. @@ -1417,6 +1399,38 @@ The contract id. The sub id. +## `RunResult` + +The result of a transaction execution. + +**fields:** + +`state`: `RunState!` + +The state of the transaction execution. + +`breakpoint`: `OutputBreakpoint` + +A breakpoint during debugging. + +`jsonReceipts`: `[String!]!` + +The receipts of the transaction in JSON format. + +## `ScriptParameters` + +The consensus parameters for a script. + +**fields:** + +`maxScriptLength`: [`U64!`](/docs/reference/scalars/#u64) + +The maximum length of a script. + +`maxScriptDataLength`: [`U64!`](/docs/reference/scalars/#u64) + +The maximum length of script data. + ## `SpendQueryElementInput` A type used in the `queryPerAsset` argument for the `resourcesToSpend` query. @@ -1585,6 +1599,32 @@ An array of storage slot. A hex string of the raw transaction payload. +## `TxParameters` + +The consensus parameters for a transaction. + +**fields:** + +`maxInputs`: [`U8!`](/docs/reference/scalars/#u8) + +The maximum number of inputs allowed for a transaction. + +`maxOutputs`: [`U8!`](/docs/reference/scalars/#u8) + +The maximum number of outputs allowed for a transaction. + +`maxWitnesses`: [`U32!`](/docs/reference/scalars/#u32) + +The maximum number of witnesses allowed for a transaction. + +`maxGasPerTx`: [`U64!`](/docs/reference/scalars/#u64) + +The maximum amoutn of gas allowed for a transaction. + +`maxSize`: [`U64!`](/docs/reference/scalars/#u64) + +The maximum size allowed for a transaction. + ## `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 fd858dd..26c54d5 100644 --- a/docs/reference/queries.mdx +++ b/docs/reference/queries.mdx @@ -135,6 +135,16 @@ The transaction hex string. Returns `true` if the API is running or `false` if the API is down. +## `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. + ## `messageProof` Returns the [`MessageProof`](/docs/reference/objects/#messageproof) for a given message id or transaction. diff --git a/docs/reference/scalars.mdx b/docs/reference/scalars.mdx index 658a1bf..e70c47d 100644 --- a/docs/reference/scalars.mdx +++ b/docs/reference/scalars.mdx @@ -57,6 +57,10 @@ 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` + +Unsigned 8 bit number. + ## `U32` Unsigned 32 bit number. diff --git a/docs/reference/subscriptions.mdx b/docs/reference/subscriptions.mdx index 23584d8..bfc6451 100644 --- a/docs/reference/subscriptions.mdx +++ b/docs/reference/subscriptions.mdx @@ -19,7 +19,7 @@ The id of the transaction to stream status updates for. ## `submitAndAwait` -Submits transaction to the `TxPool` and await returns [`TransactionStatus!`](/docs/reference/unions/#transactionstatus). +Submits a transaction to the `TxPool` and await returns the [`TransactionStatus!`](/docs/reference/unions/#transactionstatus). **args:** diff --git a/examples/tests/transactions-by-owner.test.ts b/examples/tests/transactions-by-owner.test.ts index 0899292..5db50fc 100644 --- a/examples/tests/transactions-by-owner.test.ts +++ b/examples/tests/transactions-by-owner.test.ts @@ -84,7 +84,7 @@ describe('Transactions by owner', () => { const args = { address: - '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871', + '0x44f640c8ed0d0b76fa7a029972e9db1ce92386b8e4df4d789e026443cb5f0d91', }; const getTransactions = async () => { @@ -178,7 +178,7 @@ describe('Transactions by owner', () => { const args = { address: - '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871', + '0x44f640c8ed0d0b76fa7a029972e9db1ce92386b8e4df4d789e026443cb5f0d91', }; const getTransactions = async () => { @@ -264,7 +264,7 @@ describe('Transactions by owner', () => { const args = { address: - '0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871', + '0x44f640c8ed0d0b76fa7a029972e9db1ce92386b8e4df4d789e026443cb5f0d91', }; const getTransactions = async () => { diff --git a/scripts/coverage/index.mjs b/scripts/coverage/index.mjs new file mode 100644 index 0000000..d5508e9 --- /dev/null +++ b/scripts/coverage/index.mjs @@ -0,0 +1,112 @@ +import { + GET_ENUMS, + GET_INPUT_OBJECTS, + GET_OBJECTS, + GET_QUERIES, + GET_SCALARS, + GET_UNIONS, + GET_MUTATIONS, + GET_SUBSCRIPTIONS, +} from './queries.mjs'; +import { checkQueryOrMutationHeadings, checkAndCompare } from './utils.mjs'; + +const scalarExceptions = ['Boolean', 'Float', 'ID', 'Int', 'String']; +const enumExceptions = ['__DirectiveLocation', '__TypeKind']; +const objectExceptions = [ + '__Directive', + '__EnumValue', + '__Field', + '__InputValue', + '__Schema', + '__Type', + 'Query', + 'Mutation', + 'Subscription', + 'PageInfo', +]; +const queryExceptions = ['register', 'memory']; +const mutationExceptions = []; +const subscriptionExceptions = []; +// const inputArgExceptions = ['first', 'last', 'after', 'before']; + +async function checkScalars() { + await checkAndCompare( + GET_SCALARS, + 'SCALAR', + 'docs/reference/scalars.mdx', + scalarExceptions + ); +} + +async function checkEnums() { + await checkAndCompare( + GET_ENUMS, + 'ENUM', + 'docs/reference/enums.mdx', + enumExceptions + ); +} + +async function checkUnions() { + await checkAndCompare(GET_UNIONS, 'UNION', 'docs/reference/unions.mdx'); +} + +async function checkInputObjects() { + await checkAndCompare( + GET_INPUT_OBJECTS, + 'INPUT_OBJECT', + 'docs/reference/objects.mdx' + ); +} + +async function checkObjects() { + await checkAndCompare( + GET_OBJECTS, + 'OBJECT', + 'docs/reference/objects.mdx', + objectExceptions + ); +} + +async function checkQueries() { + await checkQueryOrMutationHeadings( + 'docs/reference/queries.mdx', + GET_QUERIES, + 'QUERY', + queryExceptions, + 'queryType' + ); +} + +async function checkMutations() { + await checkQueryOrMutationHeadings( + 'docs/reference/mutations.mdx', + GET_MUTATIONS, + 'MUTATION', + mutationExceptions, + 'mutationType' + ); +} + +async function checkSubscriptions() { + await checkQueryOrMutationHeadings( + 'docs/reference/subscriptions.mdx', + GET_SUBSCRIPTIONS, + 'SUBSCRIPTION', + subscriptionExceptions, + 'subscriptionType' + ); +} + +async function checkDocs() { + await checkScalars(); + await checkEnums(); + await checkUnions(); + await checkInputObjects(); + await checkObjects(); + await checkQueries(); + await checkMutations(); + await checkSubscriptions(); +} + +await checkDocs(); diff --git a/scripts/coverage/queries.mjs b/scripts/coverage/queries.mjs new file mode 100644 index 0000000..0e41873 --- /dev/null +++ b/scripts/coverage/queries.mjs @@ -0,0 +1,239 @@ +export const GET_SCALARS = ` +query IntrospectionQuery { + __schema { + types { + kind + name + } + } +} +`; + +export const GET_ENUMS = ` +query IntrospectionQuery { + __schema { + types { + kind + name + enumValues { + name + } + } + } +} +`; + +export const GET_UNIONS = ` +query IntrospectionQuery { + __schema { + types { + kind + name + possibleTypes { + name + } + } + } +} +`; + +export const GET_INPUT_OBJECTS = ` +query IntrospectionQuery { + __schema { + types { + kind + name + inputFields { + name + type { + name + kind + } + } + } + } +} +`; + +export const GET_OBJECTS = ` +query IntrospectionQuery { + __schema { + types { + kind + name + fields { + name + type { + name + kind + } + } + } + } +} +`; + +export const GET_QUERIES = ` +query IntrospectionQuery { + __schema { + queryType { + fields { + name + args { + name + type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } + } +} +`; + +export const GET_MUTATIONS = ` +query IntrospectionQuery { + __schema { + mutationType { + fields { + name + args { + name + type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } +} +`; + +export const GET_SUBSCRIPTIONS = ` + query IntrospectionQuery { + __schema { + subscriptionType { + fields { + name + args { + name + type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } + } +`; diff --git a/scripts/coverage/utils.mjs b/scripts/coverage/utils.mjs new file mode 100644 index 0000000..986d22c --- /dev/null +++ b/scripts/coverage/utils.mjs @@ -0,0 +1,146 @@ +import { assert } from 'console'; +import { readFileSync } from 'fs'; +import remarkParse from 'remark-parse'; +import { unified } from 'unified'; +import { visit } from 'unist-util-visit'; + +const headingsExceptions = (heading) => { + if (heading.startsWith('title: ')) { + return false; + } + if ( + [ + 'Queries', + 'Mutations', + 'Subscriptions', + 'Objects', + 'Unions', + 'Enums', + 'Scalars', + ].includes(heading) + ) { + return false; + } + return true; +}; + +export async function getHeadings(filepath) { + const file = readFileSync(filepath, 'utf8'); + const processor = unified().use(remarkParse); + const ast = processor.parse(file); + const headings = []; + visit(ast, 'heading', (node) => { + headings.push(node.children[0].value); + }); + return headings.filter(headingsExceptions); +} + +async function request(query) { + const response = await fetch('https://beta-5.fuel.network/graphql', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + body: JSON.stringify({ + query, + }), + }); + const json = await response.json(); + return json; +} + +async function fetchNames(query, kind) { + try { + const response = await request(query); + const names = response.data.__schema.types + .filter((type) => type.kind === kind) + .map((type) => type.name) + .filter((name) => !name.endsWith('Connection') && !name.endsWith('Edge')); + return names; + } catch (error) { + console.error(`Error fetching ${kind} names:`, error); + return []; + } +} + +export function compare(actual, headings, exceptions, itemName) { + const missing = []; + actual.forEach((item) => { + const isIncluded = headings.includes(item); + if (!isIncluded) { + if (!exceptions.includes(item)) { + missing.push(item); + } + } + }); + assert(missing.length === 0, `MISSING FROM ${itemName}: ${missing}`); +} + +export async function checkAndCompare(query, kind, filepath, exceptions = []) { + const names = await fetchNames(query, kind); + const headings = await getHeadings(filepath); + compare(names, headings, exceptions, `${kind}s`); +} + +function getType(type) { + if (!type) { + return null; + } + + if (type.name) { + return type.name; + } + + let nestedTypeName = getType(type.ofType); + + if (type.kind === 'LIST') { + return `[${nestedTypeName}]`; + } else if (type.kind === 'NON_NULL') { + return `${nestedTypeName}!`; + } + + return nestedTypeName; +} + +function processQueryOrMutation(fields, exceptions) { + return fields + .filter((query) => !exceptions.includes(query.name)) + .map((query) => ({ + name: query.name, + args: query.args.map((arg) => ({ + name: arg.name, + type: getType(arg.type), + })), + returnType: getType(query.type), + })); +} + +export async function fetchData(query, kind, exceptions, schemaType) { + try { + const response = await request(query); + const fields = response.data.__schema[schemaType].fields; + return processQueryOrMutation(fields, exceptions); + } catch (error) { + console.error(`Error fetching ${kind} names:`, error); + return []; + } +} + +export async function checkQueryOrMutationHeadings( + filepath, + query, + kind, + exceptions, + schemaType +) { + const headings = await getHeadings(filepath); + const items = await fetchData(query, kind, exceptions, schemaType); + const missing = []; + items.forEach((item) => { + if (!headings.includes(item.name)) { + missing.push(item.name); + } + }); + assert(missing.length === 0, `MISSING FROM ${kind}: ${missing}`); +} From 7e6a68351c88c0cdd1702184297a0f1f160e4951 Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Fri, 26 Jan 2024 14:46:51 -0700 Subject: [PATCH 05/13] check for object fields --- docs/recipes.mdx | 6 +- docs/reference/objects.mdx | 126 ++++++++++++++++++----------- docs/reference/queries.mdx | 12 +-- docs/reference/scalars.mdx | 4 - docs/reference/subscriptions.mdx | 2 +- scripts/coverage/index.mjs | 47 ++--------- scripts/coverage/objects.mjs | 76 ++++++++++++++++++ scripts/coverage/queries.mjs | 8 ++ scripts/coverage/utils.mjs | 134 +++++++++++++++++++++++++++++-- 9 files changed, 309 insertions(+), 106 deletions(-) create mode 100644 scripts/coverage/objects.mjs diff --git a/docs/recipes.mdx b/docs/recipes.mdx index ad0fcf3..026ddf3 100644 --- a/docs/recipes.mdx +++ b/docs/recipes.mdx @@ -106,7 +106,7 @@ query Transactions($address: Address) { } } ... on InputMessage { - messageId + nonce sender recipient amount @@ -199,7 +199,7 @@ query LatestTransactions { } } ... on InputMessage { - messageId + nonce sender recipient amount @@ -349,7 +349,7 @@ query LatestBlocks { } } ... on InputMessage { - messageId + nonce sender recipient amount diff --git a/docs/reference/objects.mdx b/docs/reference/objects.mdx index d46b415..e9bc705 100644 --- a/docs/reference/objects.mdx +++ b/docs/reference/objects.mdx @@ -57,13 +57,15 @@ An array of transactions included in the block. ## `Breakpoint` -A breakpoint during debugging +A breakpoint during debugging. + +**fields:** `contract`: [`ContractId!`](/docs/reference/scalars/#contractid) The contract address. -`pc`: [`U64`](/docs/reference/scalars/#u64) +`pc`: [`U64!`](/docs/reference/scalars/#u64) The value of the program counter register `$pc`, which is the memory address of the current instruction. @@ -73,7 +75,7 @@ Information about the base chain. At a very high level `chainInfo` helps you und **fields:** -`name: String!` +`name`: `String!` The human-readable string name of the chain. i.e. beta-5 @@ -81,14 +83,14 @@ The human-readable string name of the chain. i.e. beta-5 The most recently created block. -`consensusParameters`: [`ConsensusParameters!`](#consensusparameters) - -The consensus parameters used to validate blocks. - `daHeight`: [`U64!`](/docs/reference/scalars/#u64) The height of the base chain via relayer (i.e. Ethereum or DA) +`consensusParameters`: [`ConsensusParameters!`](#consensusparameters) + +The consensus parameters used to validate blocks. + `gasCosts`: [`GasCosts!`](#gascosts) The gas cost of each opcode. @@ -281,7 +283,7 @@ The output type from a transaction that changed the state of a contract. **fields:** -`inputIndex: Int!` +`inputIndex`: `Int!` The index of the input. @@ -295,7 +297,9 @@ The state root of contract after transaction execution. ## `ContractParameters` -An object containing information about a contract +An object containing information about a contract. + +**fields:** `contractMaxSize`: [`U64!`](/docs/reference/scalars/#u64) @@ -337,7 +341,7 @@ The block number for the failed transaction. The time the transaction failed. -`reason: String!` +`reason`: `String!` The reason why the transaction failed. @@ -345,8 +349,16 @@ The reason why the transaction failed. The state of the program execution. +`receipts`: [`[Receipt!]!`](#receipt) + +The receipts for the transaction. + ## `FeeParameters` +The consensus parameters for fees. + +**fields:** + `gasPriceFactor`: [`U64!`](/docs/reference/scalars/#u64) The dynamic adjustment of gas costs @@ -785,21 +797,21 @@ The `dependent` gas cost of using the `$srwq` contract opcode. The `dependent` gas cost of using the `$swwq` contract opcode. -`swwq`: [`DependentCost!`](/docs/reference/unions/#dependentcost) - -The `dependent` gas cost of using the `$swwq` contract opcode. - `contractRoot`: [`DependentCost!`](/docs/reference/unions/#dependentcost) -The `dependent` gas cost calculating the `contractRoot` +The `dependent` gas cost calculating the `contractRoot`. `stateRoot`: [`DependentCost!`](/docs/reference/unions/#dependentcost) -The `dependent` gas cost calculating the `stateRoot` +The `dependent` gas cost calculating the `stateRoot`. + +`vmInitialization`: [`DependentCost!`](/docs/reference/unions/#dependentcost) + +The `dependent` gas cost of the `vmInitialization`. `newStoragePerByte`: [`U64!`](/docs/reference/scalars/#u64) -The gas cost of storage per byte +The gas cost of storage per byte. ## `Genesis` @@ -859,6 +871,10 @@ The number of transactions in the block. The number of receipt messages in the block. +`transactionsRoot`: [`Bytes32!`](/docs/reference/scalars/#bytes32) + +The merkle root of the transactions in the block. + `messageReceiptRoot`: [`Bytes32!`](/docs/reference/scalars/#bytes32) The merkle root of the receipt messages in the block. @@ -905,7 +921,7 @@ The asset ID of the coins. A pointer to the transaction whose output is being spent. -`witnessIndex: Int!` +`witnessIndex`: `Int!` The index of the witness that authorizes spending the coin. @@ -973,7 +989,7 @@ The amount sent in the message. A nonce value for the message input, which is determined by the sending system and is published at the time the message is sent. -`witnessIndex: Int!` +`witnessIndex`: `Int!` The index of witness that authorizes spending the coin. @@ -1027,10 +1043,6 @@ Contains information about a message. **fields:** -`messageId`: [`MessageId!`](/docs/reference/scalars/#messageid) - -A unique id for the message. - `amount`: [`U64!`](/docs/reference/scalars/#u64) The amount of base asset coins sent with the message. @@ -1047,7 +1059,7 @@ The recipient of the message. The nonce value for the message. -`data: [Int!]!` +`data`: `[Int!]!` The vector with the message data. @@ -1167,7 +1179,7 @@ The maximum number of connected UTXOs allowed, excluding contracts. The node version. -`peers: [`PeerInfo!`](#peerinfo)!` +`peers`: [`PeerInfo!`](#peerinfo)!` The information about the node's peers. @@ -1175,11 +1187,13 @@ The information about the node's peers. A breakpoint during debugging. +**fields:** + `contract`: [`ContractId!`](/docs/reference/scalars/#contractid) The contract address. -`pc`: [`U64`](/docs/reference/scalars/#u64) +`pc`: [`U64!`](/docs/reference/scalars/#u64) The value of the program counter register `$pc`, which is the memory address of the current instruction. @@ -1193,7 +1207,7 @@ Information about a peer node. The `libp2p` ID of the peer node. -`addresses`: [`String!`]! +`addresses`: `[String!]!` The advertised addresses that can be used to connect to this peer node. @@ -1201,11 +1215,11 @@ The advertised addresses that can be used to connect to this peer node. The self-reported version of the client the peer node is using. -`blockHeight`: `U32` +`blockHeight`: [`U32`](/docs/reference/scalars/#u32) The last reported height of the peer node. -`lastHeartbeatMs`: `U64!` +`lastHeartbeatMs`: [`U64!`](/docs/reference/scalars/#u64) The time of the last heartbeat from this peer node in unix epoch time milliseconds. @@ -1455,7 +1469,7 @@ The status for a transaction that was squeezed out of the transaction pool. **fields:** -`reason: String!` +`reason`: `String!` The reason why the transaction was squeezed out. @@ -1465,6 +1479,10 @@ The status of a successful transaction. **fields:** +`transactionId`: [`TransactionId!`](/docs/reference/scalars/#transactionid) + +The ID of the transaction. + `block`: [`Block!`](#block) The block of the transaction. @@ -1477,6 +1495,10 @@ The time of the transaction. The state of the program execution. +`receipts`: [`[Receipt!]!`](#receipt) + +The transaction receipts. + ## `SubmittedStatus` The status for a submitted transaction. @@ -1487,20 +1509,6 @@ The status for a submitted transaction. The time a transaction was submitted -## `TimeParameters` - -An object containing information about block times - -**fields:** - -`startTime`: [`U64`](/docs/reference/scalars/#u64) - -The time to set on the first block. - -`blockTimeInterval`: [`U64`](/docs/reference/scalars/#u64) - -The time interval between subsequent blocks. - ## `Transaction` An object containing information about a transaction. @@ -1519,11 +1527,19 @@ An array of asset ids used for the transaction inputs. An array of contracts used for the transaction inputs. +`inputContract`: [`InputContract`](#inputcontract) + +A contract used for the transaction input. + +`policies`: [`Policies`](#policies) + +The policies for the transaction. + `gasPrice`: [`U64`](/docs/reference/scalars/#u64) The gas price for the transaction. -`gasLimit`: [`U64`](/docs/reference/scalars/#u64) +`scriptGasLimit`: [`U64`](/docs/reference/scalars/#u64) The gas limit for the transaction. @@ -1531,19 +1547,27 @@ The gas limit for the transaction. The minimum block height that the transaction can be included at. +`mintAmount`: [`U64`](/docs/reference/scalars/#u64) + +The amount minted in the transaction. + +`mintAssetId`: [`AssetId`](/docs/reference/scalars/#assetid) + +The asset ID for coins minted in the transaction. + `txPointer`: [`TxPointer`](/docs/reference/scalars/#txpointer) The location of the transaction in the block. -`isScript: Boolean!` +`isScript`: `Boolean!` Whether or not the transaction is a script. -`isCreate: Boolean!` +`isCreate`: `Boolean!` Whether or not the transaction is creating a new contract. -`isMint: Boolean!` +`isMint`: `Boolean!` Whether or not the transaction is minting new coins. @@ -1555,6 +1579,10 @@ An array of inputs for the transaction. An array of outputs for the transaction. +`outputContract`: [`ContractOutput`](#contractoutput) + +The contract output for the transaction. + `witnesses`: [`[HexString!]`](/docs/reference/scalars/#hexstring) An array of witnesses. @@ -1579,7 +1607,7 @@ The script to execute. The script input parameters. -`bytecodeWitnessIndex: Int` +`bytecodeWitnessIndex`: `Int` The witness index of contract bytecode. diff --git a/docs/reference/queries.mdx b/docs/reference/queries.mdx index 26c54d5..553f2c1 100644 --- a/docs/reference/queries.mdx +++ b/docs/reference/queries.mdx @@ -127,7 +127,9 @@ A filter for the contract balances. Estimate the predicate gas and returns a [`Transaction!`](/docs/reference/objects/#transaction). -`tx:` [`HexString!`](/docs/reference/scalars/#hexstring) +**args:** + +`tx`: [`HexString!`](/docs/reference/scalars/#hexstring) The transaction hex string. @@ -155,15 +157,15 @@ Returns the [`MessageProof`](/docs/reference/objects/#messageproof) for a given The transaction id for the message. -`messageId`: [`MessageId!`](/docs/reference/scalars/#messageid) +`nonce`: [`Nonce`](/docs/reference/scalars/#nonce) -The id of the message. +The message nonce. -`id`: [`BlockId`](/docs/reference/scalars/#blockid) +`commitBlockId`: [`BlockId`](/docs/reference/scalars/#blockid) The block id. -`height`: [`U64`](/docs/reference/scalars/#u64) +`commitBlockHeight`: [`U32`](/docs/reference/scalars/#u32) The block height. diff --git a/docs/reference/scalars.mdx b/docs/reference/scalars.mdx index e70c47d..fa008f1 100644 --- a/docs/reference/scalars.mdx +++ b/docs/reference/scalars.mdx @@ -29,10 +29,6 @@ A wrapped 32byte hash that is used to uniquely identify a contract. A way to pass in bytes as hex data. This is used for variable byte length types. Predicates and predicate data are always a hex string. -## `MessageId` - -A 32 byte identifier for cross-network messages, like messages from Ethereum to Fuel. - ## `Nonce` A random or pseudo-random number generated for a single use to ensure data freshness and prevent replay attacks. diff --git a/docs/reference/subscriptions.mdx b/docs/reference/subscriptions.mdx index bfc6451..4d05cfb 100644 --- a/docs/reference/subscriptions.mdx +++ b/docs/reference/subscriptions.mdx @@ -23,6 +23,6 @@ Submits a transaction to the `TxPool` and await returns the [`TransactionStatus! **args:** -`tx:` [`HexString!`](/docs/reference/scalars/#hexstring) +`tx`: [`HexString!`](/docs/reference/scalars/#hexstring) The transaction hex string. diff --git a/scripts/coverage/index.mjs b/scripts/coverage/index.mjs index d5508e9..c81d776 100644 --- a/scripts/coverage/index.mjs +++ b/scripts/coverage/index.mjs @@ -1,33 +1,20 @@ +import { checkAllObjects } from './objects.mjs'; import { GET_ENUMS, - GET_INPUT_OBJECTS, - GET_OBJECTS, GET_QUERIES, GET_SCALARS, GET_UNIONS, GET_MUTATIONS, GET_SUBSCRIPTIONS, } from './queries.mjs'; -import { checkQueryOrMutationHeadings, checkAndCompare } from './utils.mjs'; +import { checkHeadings, checkAndCompare } from './utils.mjs'; const scalarExceptions = ['Boolean', 'Float', 'ID', 'Int', 'String']; const enumExceptions = ['__DirectiveLocation', '__TypeKind']; -const objectExceptions = [ - '__Directive', - '__EnumValue', - '__Field', - '__InputValue', - '__Schema', - '__Type', - 'Query', - 'Mutation', - 'Subscription', - 'PageInfo', -]; + const queryExceptions = ['register', 'memory']; const mutationExceptions = []; const subscriptionExceptions = []; -// const inputArgExceptions = ['first', 'last', 'after', 'before']; async function checkScalars() { await checkAndCompare( @@ -51,25 +38,8 @@ async function checkUnions() { await checkAndCompare(GET_UNIONS, 'UNION', 'docs/reference/unions.mdx'); } -async function checkInputObjects() { - await checkAndCompare( - GET_INPUT_OBJECTS, - 'INPUT_OBJECT', - 'docs/reference/objects.mdx' - ); -} - -async function checkObjects() { - await checkAndCompare( - GET_OBJECTS, - 'OBJECT', - 'docs/reference/objects.mdx', - objectExceptions - ); -} - async function checkQueries() { - await checkQueryOrMutationHeadings( + await checkHeadings( 'docs/reference/queries.mdx', GET_QUERIES, 'QUERY', @@ -79,7 +49,7 @@ async function checkQueries() { } async function checkMutations() { - await checkQueryOrMutationHeadings( + await checkHeadings( 'docs/reference/mutations.mdx', GET_MUTATIONS, 'MUTATION', @@ -89,7 +59,7 @@ async function checkMutations() { } async function checkSubscriptions() { - await checkQueryOrMutationHeadings( + await checkHeadings( 'docs/reference/subscriptions.mdx', GET_SUBSCRIPTIONS, 'SUBSCRIPTION', @@ -102,10 +72,9 @@ async function checkDocs() { await checkScalars(); await checkEnums(); await checkUnions(); - await checkInputObjects(); - await checkObjects(); + await checkAllObjects(); await checkQueries(); - await checkMutations(); + // await checkMutations(); await checkSubscriptions(); } diff --git a/scripts/coverage/objects.mjs b/scripts/coverage/objects.mjs new file mode 100644 index 0000000..f233280 --- /dev/null +++ b/scripts/coverage/objects.mjs @@ -0,0 +1,76 @@ +import { assert } from 'console'; + +import { GET_INPUT_OBJECTS, GET_OBJECTS } from './queries.mjs'; +import { + fetchObjects, + compare, + getHeadings, + getArgsOrFields, + checkIfEqual, +} from './utils.mjs'; + +const objectExceptions = [ + '__Directive', + '__EnumValue', + '__Field', + '__InputValue', + '__Schema', + '__Type', + 'Query', + 'Mutation', + 'Subscription', + 'PageInfo', +]; + +export async function checkAllObjects() { + const filepath = 'docs/reference/objects.mdx'; + const headings = await getHeadings(filepath); + + const inputObjects = await fetchObjects(GET_INPUT_OBJECTS, 'INPUT_OBJECT'); + // console.log('INPUT_OBJECTS', inputObjects); + const inputObjectNames = inputObjects.map((item) => item.name); + compare(inputObjectNames, headings, [], `INPUT_OBJECTs`); + + const objects = await fetchObjects(GET_OBJECTS, 'OBJECT'); + const objectNames = objects.map((item) => item.name); + compare(objectNames, headings, objectExceptions, `OBJECTs`); + + const fields = getArgsOrFields(filepath, 'fields:'); + + const actual = [...inputObjects, ...objects].filter( + (item) => !objectExceptions.includes(item.name) + ); + const extraHeadings = []; + headings.forEach((item) => { + if (!actual.map((item) => item.name).includes(item)) { + extraHeadings.push(item); + } + }); + + assert( + extraHeadings.length === 0, + `EXTRA HEADINGS IN OBJECTS: ${extraHeadings}` + ); + + const wrongFields = []; + actual.forEach((item) => { + if (item.fields) { + const fieldsFromDocs = fields[item.name]; + if (!fieldsFromDocs) { + console.log('NO FIELDS IN DOCS:', item.name); + wrongFields.push(item.name); + } else { + const fieldsMatch = checkIfEqual(item.fields, fieldsFromDocs); + if (!fieldsMatch) { + console.log( + `DIFF FIELDS IN DOCS FOR ${item.name}:`, + item.fields, + fieldsFromDocs + ); + wrongFields.push(item.name); + } + } + } + }); + assert(wrongFields.length === 0, `WRONG FIELDS IN OBJECTS: ${wrongFields}`); +} diff --git a/scripts/coverage/queries.mjs b/scripts/coverage/queries.mjs index 0e41873..f60a72b 100644 --- a/scripts/coverage/queries.mjs +++ b/scripts/coverage/queries.mjs @@ -48,6 +48,10 @@ query IntrospectionQuery { type { name kind + ofType { + kind + name + } } } } @@ -66,6 +70,10 @@ query IntrospectionQuery { type { name kind + ofType { + kind + name + } } } } diff --git a/scripts/coverage/utils.mjs b/scripts/coverage/utils.mjs index 986d22c..48d2ba0 100644 --- a/scripts/coverage/utils.mjs +++ b/scripts/coverage/utils.mjs @@ -4,6 +4,8 @@ import remarkParse from 'remark-parse'; import { unified } from 'unified'; import { visit } from 'unist-util-visit'; +const inputArgExceptions = ['first', 'last', 'after', 'before']; + const headingsExceptions = (heading) => { if (heading.startsWith('title: ')) { return false; @@ -14,7 +16,7 @@ const headingsExceptions = (heading) => { 'Mutations', 'Subscriptions', 'Objects', - 'Unions', + 'Union Types', 'Enums', 'Scalars', ].includes(heading) @@ -50,7 +52,34 @@ async function request(query) { return json; } -async function fetchNames(query, kind) { +export async function fetchObjects(query, kind) { + try { + const response = await request(query); + const objects = response.data.__schema.types + .filter((type) => type.kind === kind) + .filter( + (type) => + !type.name.endsWith('Connection') && !type.name.endsWith('Edge') + ) + .map((item) => { + const newItem = { name: item.name }; + const fields = item.fields || item.inputFields; + if (fields) { + newItem.fields = fields.map((field) => ({ + name: field.name, + type: getType(field.type), + })); + } + return newItem; + }); + return objects; + } catch (error) { + console.error(`Error fetching ${kind} names:`, error); + return []; + } +} + +export async function fetchNames(query, kind) { try { const response = await request(query); const names = response.data.__schema.types @@ -75,6 +104,22 @@ export function compare(actual, headings, exceptions, itemName) { } }); assert(missing.length === 0, `MISSING FROM ${itemName}: ${missing}`); + + if (itemName === 'INPUT_OBJECTs' || itemName === 'OBJECTs') { + return; + } + + const extraHeadings = []; + headings.forEach((item) => { + if (!actual.includes(item)) { + extraHeadings.push(item); + } + }); + + assert( + extraHeadings.length === 0, + `EXTRA HEADINGS IN ${itemName}: ${extraHeadings}` + ); } export async function checkAndCompare(query, kind, filepath, exceptions = []) { @@ -103,7 +148,7 @@ function getType(type) { return nestedTypeName; } -function processQueryOrMutation(fields, exceptions) { +function processData(fields, exceptions) { return fields .filter((query) => !exceptions.includes(query.name)) .map((query) => ({ @@ -120,14 +165,69 @@ export async function fetchData(query, kind, exceptions, schemaType) { try { const response = await request(query); const fields = response.data.__schema[schemaType].fields; - return processQueryOrMutation(fields, exceptions); + return processData(fields, exceptions); } catch (error) { console.error(`Error fetching ${kind} names:`, error); return []; } } -export async function checkQueryOrMutationHeadings( +export function getArgsOrFields(filepath, name) { + const file = readFileSync(filepath, 'utf8'); + const processor = unified().use(remarkParse); + const ast = processor.parse(file); + const headingArgs = {}; + let currentHeading = ''; + let currentIndex = 0; + const args = {}; + visit(ast, '', (node, _i, parent) => { + if (node.type === 'heading') { + currentHeading = node.children[0].value; + } + + if (node.value === name) { + headingArgs[currentHeading] = true; + } + + if (headingArgs[currentHeading] && node.type === 'inlineCode') { + if ( + (parent.children[1] && parent.children[1].value === ': ') || + parent.children[1] === undefined + ) { + if (args[currentHeading] && !args[currentHeading][currentIndex].type) { + args[currentHeading][currentIndex].type = node.value; + } else { + if (!args[currentHeading]) { + args[currentHeading] = []; + } + args[currentHeading].push({ name: node.value }); + currentIndex = args[currentHeading].length - 1; + } + } + } + }); + return args; +} + +export function checkIfEqual(a, b) { + if (a.length !== b.length) { + console.log('DIFFERENT LENGTHS'); + return false; + } + + return a.every((value, index) => { + const bVal = b[index]; + const isEqual = value.id === bVal.id && value.name === bVal.name; + if (!isEqual) { + console.log('!!!!!!NOT EQUAL!!!!'); + console.log('VALUE A:', value); + console.log('VALUE B:', bVal); + } + return isEqual; + }); +} + +export async function checkHeadings( filepath, query, kind, @@ -135,12 +235,36 @@ export async function checkQueryOrMutationHeadings( schemaType ) { const headings = await getHeadings(filepath); + const args = getArgsOrFields(filepath, 'args:'); const items = await fetchData(query, kind, exceptions, schemaType); const missing = []; + const wrongArgs = []; items.forEach((item) => { if (!headings.includes(item.name)) { missing.push(item.name); } + + const cleanedArgs = item.args.filter( + (arg) => !inputArgExceptions.includes(arg.name) + ); + if (cleanedArgs && cleanedArgs.length > 0) { + const argsFromDocs = args[item.name]; + if (!argsFromDocs) { + console.log('NO ARGS IN DOCS:', item.name); + wrongArgs.push(item.name); + } else { + const argsMatch = checkIfEqual(cleanedArgs, argsFromDocs); + if (!argsMatch) { + console.log( + `DIFF ARGS IN DOCS FOR ${item.name}:`, + cleanedArgs, + argsFromDocs + ); + wrongArgs.push(item.name); + } + } + } }); assert(missing.length === 0, `MISSING FROM ${kind}: ${missing}`); + assert(wrongArgs.length === 0, `ARGS ARE WRONG IN ${kind}: ${wrongArgs}`); } From 9eb5843ac8bc4ebe42b3fcce449ed7e2ea28037e Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Sun, 28 Jan 2024 09:52:21 -0700 Subject: [PATCH 06/13] Check union types --- docs/reference/unions.mdx | 9 ++-- scripts/coverage/index.mjs | 8 +--- scripts/coverage/objects.mjs | 50 ++++++++++++++++++-- scripts/coverage/unions.mjs | 91 ++++++++++++++++++++++++++++++++++++ scripts/coverage/utils.mjs | 38 ++++----------- 5 files changed, 152 insertions(+), 44 deletions(-) create mode 100644 scripts/coverage/unions.mjs diff --git a/docs/reference/unions.mdx b/docs/reference/unions.mdx index 25889f2..e4e21b8 100644 --- a/docs/reference/unions.mdx +++ b/docs/reference/unions.mdx @@ -11,9 +11,9 @@ The type of coin being used. **Types:** -[`Coin`](/docs/reference/objects/#coin): Coin +[`Coin`](/docs/reference/objects/#coin): A standard coin. -[`MessageCoin`](/docs/reference/objects/#messagecoin): `MessageCoin` +[`MessageCoin`](/docs/reference/objects/#messagecoin): A message coin. ## `Consensus` @@ -58,7 +58,8 @@ An output type for a transaction. **Types:** [`CoinOutput`](/docs/reference/objects/#coinoutput): Indicates coins -were forwarded from one address to another. +were forwarded from one address to another. +Can be used during transaction creation when the recipient, asset, and amount is known. [`ContractOutput`](/docs/reference/objects/#contractoutput): Indicates the transaction updated the state of a contract. @@ -81,6 +82,8 @@ Indicates a contract was deployed. The status type of a transaction. +**Types:** + [`SubmittedStatus`](/docs/reference/objects/#submittedstatus): The transaction has been submitted. [`SuccessStatus`](/docs/reference/objects/#successstatus): The transaction has succeeded. diff --git a/scripts/coverage/index.mjs b/scripts/coverage/index.mjs index c81d776..a6feb77 100644 --- a/scripts/coverage/index.mjs +++ b/scripts/coverage/index.mjs @@ -3,10 +3,10 @@ import { GET_ENUMS, GET_QUERIES, GET_SCALARS, - GET_UNIONS, GET_MUTATIONS, GET_SUBSCRIPTIONS, } from './queries.mjs'; +import { checkUnions } from './unions.mjs'; import { checkHeadings, checkAndCompare } from './utils.mjs'; const scalarExceptions = ['Boolean', 'Float', 'ID', 'Int', 'String']; @@ -34,10 +34,6 @@ async function checkEnums() { ); } -async function checkUnions() { - await checkAndCompare(GET_UNIONS, 'UNION', 'docs/reference/unions.mdx'); -} - async function checkQueries() { await checkHeadings( 'docs/reference/queries.mdx', @@ -74,7 +70,7 @@ async function checkDocs() { await checkUnions(); await checkAllObjects(); await checkQueries(); - // await checkMutations(); + await checkMutations(); await checkSubscriptions(); } diff --git a/scripts/coverage/objects.mjs b/scripts/coverage/objects.mjs index f233280..b2a9a60 100644 --- a/scripts/coverage/objects.mjs +++ b/scripts/coverage/objects.mjs @@ -2,11 +2,12 @@ import { assert } from 'console'; import { GET_INPUT_OBJECTS, GET_OBJECTS } from './queries.mjs'; import { - fetchObjects, compare, getHeadings, getArgsOrFields, checkIfEqual, + request, + getType, } from './utils.mjs'; const objectExceptions = [ @@ -22,12 +23,47 @@ const objectExceptions = [ 'PageInfo', ]; +// checks to make sure: +// every INPUT_OBJECT and OBJECT from the API is included in the headings in docs/reference/objects.mdx +// there are no headings that are not in the API +// all fields in the API match the fields in the docs export async function checkAllObjects() { const filepath = 'docs/reference/objects.mdx'; const headings = await getHeadings(filepath); + const actual = await checkHeadings(headings); + checkForExtraHeadings(actual, headings); + checkObjectFields(actual, filepath); +} + +async function fetchObjects(query, kind) { + try { + const response = await request(query); + const objects = response.data.__schema.types + .filter((type) => type.kind === kind) + .filter( + (type) => + !type.name.endsWith('Connection') && !type.name.endsWith('Edge') + ) + .map((item) => { + const newItem = { name: item.name }; + const fields = item.fields || item.inputFields; + if (fields) { + newItem.fields = fields.map((field) => ({ + name: field.name, + type: getType(field.type), + })); + } + return newItem; + }); + return objects; + } catch (error) { + console.error(`Error fetching ${kind} names:`, error); + return []; + } +} +async function checkHeadings(headings) { const inputObjects = await fetchObjects(GET_INPUT_OBJECTS, 'INPUT_OBJECT'); - // console.log('INPUT_OBJECTS', inputObjects); const inputObjectNames = inputObjects.map((item) => item.name); compare(inputObjectNames, headings, [], `INPUT_OBJECTs`); @@ -35,23 +71,27 @@ export async function checkAllObjects() { const objectNames = objects.map((item) => item.name); compare(objectNames, headings, objectExceptions, `OBJECTs`); - const fields = getArgsOrFields(filepath, 'fields:'); - const actual = [...inputObjects, ...objects].filter( (item) => !objectExceptions.includes(item.name) ); + return actual; +} + +function checkForExtraHeadings(actual, headings) { const extraHeadings = []; headings.forEach((item) => { if (!actual.map((item) => item.name).includes(item)) { extraHeadings.push(item); } }); - assert( extraHeadings.length === 0, `EXTRA HEADINGS IN OBJECTS: ${extraHeadings}` ); +} +function checkObjectFields(actual, filepath) { + const fields = getArgsOrFields(filepath, 'fields:'); const wrongFields = []; actual.forEach((item) => { if (item.fields) { diff --git a/scripts/coverage/unions.mjs b/scripts/coverage/unions.mjs new file mode 100644 index 0000000..1f9f537 --- /dev/null +++ b/scripts/coverage/unions.mjs @@ -0,0 +1,91 @@ +import { assert } from 'console'; +import { visit } from 'unist-util-visit'; + +import { GET_UNIONS } from './queries.mjs'; +import { + checkIfEqual, + request, + getAST, + getHeadings, + compare, +} from './utils.mjs'; + +async function fetchUnions(query, kind) { + try { + const response = await request(query); + const objects = response.data.__schema.types + .filter((type) => type.kind === kind) + .filter( + (type) => + !type.name.endsWith('Connection') && !type.name.endsWith('Edge') + ); + return objects; + } catch (error) { + console.error(`Error fetching ${kind} names:`, error); + return []; + } +} + +export function getUnionFieldsFromDocs(filepath) { + const ast = getAST(filepath); + const headingArgs = {}; + let currentHeading = ''; + const args = {}; + visit(ast, '', (node, _i, parent) => { + if (node.type === 'heading') { + currentHeading = node.children[0].value; + } + + if (node.value === 'Types:') { + headingArgs[currentHeading] = true; + } + + if ( + headingArgs[currentHeading] && + node.type === 'inlineCode' && + parent.type !== 'paragraph' + ) { + if (!args[currentHeading]) { + args[currentHeading] = []; + } + args[currentHeading].push({ name: node.value }); + } + }); + return args; +} + +function checkUnionFields(unions, unionsFromDocs) { + const wrongFields = []; + unions.forEach((item) => { + if (item.possibleTypes) { + const fieldsFromDocs = unionsFromDocs[item.name]; + if (!fieldsFromDocs) { + console.log('NO FIELDS IN DOCS:', item.name); + wrongFields.push(item.name); + } else { + const fieldsMatch = checkIfEqual(item.possibleTypes, fieldsFromDocs); + if (!fieldsMatch) { + console.log( + `DIFF FIELDS IN DOCS FOR ${item.name}:`, + item.possibleTypes, + fieldsFromDocs + ); + wrongFields.push(item.name); + } + } + } + }); + assert(wrongFields.length === 0, `WRONG FIELDS IN UNIONS: ${wrongFields}`); +} + +export async function checkUnions() { + const filepath = 'docs/reference/unions.mdx'; + const unions = await fetchUnions(GET_UNIONS, 'UNION'); + + const unionNames = unions.map((union) => union.name); + const headings = await getHeadings(filepath); + compare(unionNames, headings, [], 'UNIONs'); + + const unionsFromDocs = getUnionFieldsFromDocs(filepath); + checkUnionFields(unions, unionsFromDocs); +} diff --git a/scripts/coverage/utils.mjs b/scripts/coverage/utils.mjs index 48d2ba0..ba07f1f 100644 --- a/scripts/coverage/utils.mjs +++ b/scripts/coverage/utils.mjs @@ -37,7 +37,7 @@ export async function getHeadings(filepath) { return headings.filter(headingsExceptions); } -async function request(query) { +export async function request(query) { const response = await fetch('https://beta-5.fuel.network/graphql', { method: 'POST', headers: { @@ -52,33 +52,6 @@ async function request(query) { return json; } -export async function fetchObjects(query, kind) { - try { - const response = await request(query); - const objects = response.data.__schema.types - .filter((type) => type.kind === kind) - .filter( - (type) => - !type.name.endsWith('Connection') && !type.name.endsWith('Edge') - ) - .map((item) => { - const newItem = { name: item.name }; - const fields = item.fields || item.inputFields; - if (fields) { - newItem.fields = fields.map((field) => ({ - name: field.name, - type: getType(field.type), - })); - } - return newItem; - }); - return objects; - } catch (error) { - console.error(`Error fetching ${kind} names:`, error); - return []; - } -} - export async function fetchNames(query, kind) { try { const response = await request(query); @@ -128,7 +101,7 @@ export async function checkAndCompare(query, kind, filepath, exceptions = []) { compare(names, headings, exceptions, `${kind}s`); } -function getType(type) { +export function getType(type) { if (!type) { return null; } @@ -172,10 +145,15 @@ export async function fetchData(query, kind, exceptions, schemaType) { } } -export function getArgsOrFields(filepath, name) { +export function getAST(filepath) { const file = readFileSync(filepath, 'utf8'); const processor = unified().use(remarkParse); const ast = processor.parse(file); + return ast; +} + +export function getArgsOrFields(filepath, name) { + const ast = getAST(filepath); const headingArgs = {}; let currentHeading = ''; let currentIndex = 0; From a8521d5a2f9707db8d770ecccdc9134e762a6c53 Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Sun, 28 Jan 2024 10:32:35 -0700 Subject: [PATCH 07/13] check enum types --- scripts/coverage/enums.mjs | 47 +++++++++++++++++++++++++++++++++++ scripts/coverage/index.mjs | 12 +-------- scripts/coverage/unions.mjs | 49 +++---------------------------------- scripts/coverage/utils.mjs | 42 +++++++++++++++++++++++++++---- 4 files changed, 89 insertions(+), 61 deletions(-) create mode 100644 scripts/coverage/enums.mjs diff --git a/scripts/coverage/enums.mjs b/scripts/coverage/enums.mjs new file mode 100644 index 0000000..570501e --- /dev/null +++ b/scripts/coverage/enums.mjs @@ -0,0 +1,47 @@ +import { visit } from 'unist-util-visit'; + +import { GET_ENUMS } from './queries.mjs'; +import { + fetchItems, + compare, + getHeadings, + getAST, + compareFields, +} from './utils.mjs'; + +const enumExceptions = ['__DirectiveLocation', '__TypeKind']; + +export function getEnumValuesFromDocs(filepath) { + const ast = getAST(filepath); + let currentHeading; + const args = {}; + visit(ast, '', (node, _i, parent) => { + if (node.type === 'heading') { + currentHeading = node.children[0].value; + } else if ( + currentHeading && + currentHeading !== node.value && + node.type === 'inlineCode' && + parent.children[0].value === node.value && + parent.children[1] + ) { + if (!args[currentHeading]) { + args[currentHeading] = []; + } + args[currentHeading].push({ name: node.value }); + } + }); + return args; +} + +export async function checkEnums() { + const filepath = 'docs/reference/enums.mdx'; + const rawEnums = await fetchItems(GET_ENUMS, 'ENUM'); + const enums = rawEnums.filter((item) => !enumExceptions.includes(item.name)); + const names = enums.map((item) => item.name); + const headings = await getHeadings(filepath); + compare(names, headings, enumExceptions, `ENUMs`); + + const fieldsFromDocs = getEnumValuesFromDocs(filepath); + compareFields(enums, fieldsFromDocs, 'enumValues', 'ENUM'); +} diff --git a/scripts/coverage/index.mjs b/scripts/coverage/index.mjs index a6feb77..1af0f77 100644 --- a/scripts/coverage/index.mjs +++ b/scripts/coverage/index.mjs @@ -1,6 +1,6 @@ +import { checkEnums } from './enums.mjs'; import { checkAllObjects } from './objects.mjs'; import { - GET_ENUMS, GET_QUERIES, GET_SCALARS, GET_MUTATIONS, @@ -10,7 +10,6 @@ import { checkUnions } from './unions.mjs'; import { checkHeadings, checkAndCompare } from './utils.mjs'; const scalarExceptions = ['Boolean', 'Float', 'ID', 'Int', 'String']; -const enumExceptions = ['__DirectiveLocation', '__TypeKind']; const queryExceptions = ['register', 'memory']; const mutationExceptions = []; @@ -25,15 +24,6 @@ async function checkScalars() { ); } -async function checkEnums() { - await checkAndCompare( - GET_ENUMS, - 'ENUM', - 'docs/reference/enums.mdx', - enumExceptions - ); -} - async function checkQueries() { await checkHeadings( 'docs/reference/queries.mdx', diff --git a/scripts/coverage/unions.mjs b/scripts/coverage/unions.mjs index 1f9f537..03ebe60 100644 --- a/scripts/coverage/unions.mjs +++ b/scripts/coverage/unions.mjs @@ -1,31 +1,14 @@ -import { assert } from 'console'; import { visit } from 'unist-util-visit'; import { GET_UNIONS } from './queries.mjs'; import { - checkIfEqual, - request, + compareFields, + fetchItems, getAST, getHeadings, compare, } from './utils.mjs'; -async function fetchUnions(query, kind) { - try { - const response = await request(query); - const objects = response.data.__schema.types - .filter((type) => type.kind === kind) - .filter( - (type) => - !type.name.endsWith('Connection') && !type.name.endsWith('Edge') - ); - return objects; - } catch (error) { - console.error(`Error fetching ${kind} names:`, error); - return []; - } -} - export function getUnionFieldsFromDocs(filepath) { const ast = getAST(filepath); const headingArgs = {}; @@ -54,38 +37,14 @@ export function getUnionFieldsFromDocs(filepath) { return args; } -function checkUnionFields(unions, unionsFromDocs) { - const wrongFields = []; - unions.forEach((item) => { - if (item.possibleTypes) { - const fieldsFromDocs = unionsFromDocs[item.name]; - if (!fieldsFromDocs) { - console.log('NO FIELDS IN DOCS:', item.name); - wrongFields.push(item.name); - } else { - const fieldsMatch = checkIfEqual(item.possibleTypes, fieldsFromDocs); - if (!fieldsMatch) { - console.log( - `DIFF FIELDS IN DOCS FOR ${item.name}:`, - item.possibleTypes, - fieldsFromDocs - ); - wrongFields.push(item.name); - } - } - } - }); - assert(wrongFields.length === 0, `WRONG FIELDS IN UNIONS: ${wrongFields}`); -} - export async function checkUnions() { const filepath = 'docs/reference/unions.mdx'; - const unions = await fetchUnions(GET_UNIONS, 'UNION'); + const unions = await fetchItems(GET_UNIONS, 'UNION'); const unionNames = unions.map((union) => union.name); const headings = await getHeadings(filepath); compare(unionNames, headings, [], 'UNIONs'); const unionsFromDocs = getUnionFieldsFromDocs(filepath); - checkUnionFields(unions, unionsFromDocs); + compareFields(unions, unionsFromDocs, 'possibleTypes', 'UNION'); } diff --git a/scripts/coverage/utils.mjs b/scripts/coverage/utils.mjs index ba07f1f..f64e1e7 100644 --- a/scripts/coverage/utils.mjs +++ b/scripts/coverage/utils.mjs @@ -52,20 +52,28 @@ export async function request(query) { return json; } -export async function fetchNames(query, kind) { +export async function fetchItems(query, kind) { try { const response = await request(query); - const names = response.data.__schema.types + const objects = response.data.__schema.types .filter((type) => type.kind === kind) - .map((type) => type.name) - .filter((name) => !name.endsWith('Connection') && !name.endsWith('Edge')); - return names; + .filter( + (type) => + !type.name.endsWith('Connection') && !type.name.endsWith('Edge') + ); + return objects; } catch (error) { console.error(`Error fetching ${kind} names:`, error); return []; } } +export async function fetchNames(query, kind) { + const objects = await fetchItems(query, kind); + const names = objects.map((object) => object.name); + return names; +} + export function compare(actual, headings, exceptions, itemName) { const missing = []; actual.forEach((item) => { @@ -246,3 +254,27 @@ export async function checkHeadings( assert(missing.length === 0, `MISSING FROM ${kind}: ${missing}`); assert(wrongArgs.length === 0, `ARGS ARE WRONG IN ${kind}: ${wrongArgs}`); } + +export function compareFields(actual, docs, fieldName, kind) { + const wrongFields = []; + actual.forEach((item) => { + if (item[fieldName]) { + const fieldsFromDocs = docs[item.name]; + if (!fieldsFromDocs) { + console.log('NO FIELDS IN DOCS:', item.name); + wrongFields.push(item.name); + } else { + const fieldsMatch = checkIfEqual(item[fieldName], fieldsFromDocs); + if (!fieldsMatch) { + console.log( + `DIFF FIELDS IN DOCS FOR ${item.name}:`, + item[fieldName], + fieldsFromDocs + ); + wrongFields.push(item.name); + } + } + } + }); + assert(wrongFields.length === 0, `WRONG FIELDS IN ${kind}: ${wrongFields}`); +} From 6b3eefb9bf69f6da0abfc59ff30537d50c16817c Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Sun, 28 Jan 2024 10:43:06 -0700 Subject: [PATCH 08/13] cleanup --- scripts/coverage/index.mjs | 22 ++++++++++------------ scripts/coverage/utils.mjs | 6 ------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/scripts/coverage/index.mjs b/scripts/coverage/index.mjs index 1af0f77..162a66a 100644 --- a/scripts/coverage/index.mjs +++ b/scripts/coverage/index.mjs @@ -7,21 +7,15 @@ import { GET_SUBSCRIPTIONS, } from './queries.mjs'; import { checkUnions } from './unions.mjs'; -import { checkHeadings, checkAndCompare } from './utils.mjs'; +import { checkHeadings, fetchNames, getHeadings, compare } from './utils.mjs'; const scalarExceptions = ['Boolean', 'Float', 'ID', 'Int', 'String']; - const queryExceptions = ['register', 'memory']; -const mutationExceptions = []; -const subscriptionExceptions = []; async function checkScalars() { - await checkAndCompare( - GET_SCALARS, - 'SCALAR', - 'docs/reference/scalars.mdx', - scalarExceptions - ); + const names = await fetchNames(GET_SCALARS, 'SCALAR'); + const headings = await getHeadings('docs/reference/scalars.mdx'); + compare(names, headings, scalarExceptions, 'SCALARs'); } async function checkQueries() { @@ -39,7 +33,7 @@ async function checkMutations() { 'docs/reference/mutations.mdx', GET_MUTATIONS, 'MUTATION', - mutationExceptions, + [], 'mutationType' ); } @@ -49,7 +43,7 @@ async function checkSubscriptions() { 'docs/reference/subscriptions.mdx', GET_SUBSCRIPTIONS, 'SUBSCRIPTION', - subscriptionExceptions, + [], 'subscriptionType' ); } @@ -65,3 +59,7 @@ async function checkDocs() { } await checkDocs(); + +// TODO: +// CHECK FOR RETURN TYPES FOR QUERIES, MUTATIONS, SUBSCRIPTIONS +// CHECK FOR LINKS TO RELEVANT TYPES diff --git a/scripts/coverage/utils.mjs b/scripts/coverage/utils.mjs index f64e1e7..57f4503 100644 --- a/scripts/coverage/utils.mjs +++ b/scripts/coverage/utils.mjs @@ -103,12 +103,6 @@ export function compare(actual, headings, exceptions, itemName) { ); } -export async function checkAndCompare(query, kind, filepath, exceptions = []) { - const names = await fetchNames(query, kind); - const headings = await getHeadings(filepath); - compare(names, headings, exceptions, `${kind}s`); -} - export function getType(type) { if (!type) { return null; From 903fb0e88a1698c990f1a90fcb612c08e1daf061 Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Sun, 28 Jan 2024 10:53:51 -0700 Subject: [PATCH 09/13] cleanup --- .github/workflows/docs.yml | 14 +++++++++++ docs/reference/mutations.mdx | 48 ++++++++++++++++++------------------ scripts/coverage/utils.mjs | 2 +- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 513e705..e3f547f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -59,4 +59,18 @@ jobs: npm install npm run lint:docs:check + check-coverage: + name: Check Coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + # RUN COVERAGE CHECK + - name: Coverage Check + run: | + npm install + node scripts/coverage/index.mjs + diff --git a/docs/reference/mutations.mdx b/docs/reference/mutations.mdx index 93f7f83..01b6439 100644 --- a/docs/reference/mutations.mdx +++ b/docs/reference/mutations.mdx @@ -9,53 +9,53 @@ category: Reference ## `startSession` -### `startSession` `args` +**args:** -`id: ID!` +`id`: `ID!` returns `Boolean!` ## `endSession` -### `endSession` `args` +**args:** -`id: ID!` +`id`: `ID!` returns `Boolean!` ## `reset` -### `reset` `args` +**args:** -`id: ID!` +`id`: `ID!` returns `Boolean!` ## `execute` -### `execute` `args` +**args:** -`id: ID!` +`id`: `ID!` -`op: String!` +`op`: `String!` returns `Boolean!` ## `setSingleStepping` -### `setSingleStepping` `args` +**args:** -`id: ID!` +`id`: `ID!` -`enable: boolean` +`enable`: `boolean` returns `Boolean!` ## `setBreakpoint` -### `setBreakpoint` `args` +**args:** -`id: ID!` +`id`: `ID!` `breakpoint`: [`Breakpoint!`](/docs/reference/objects/#breakpoint) @@ -63,19 +63,19 @@ returns `Boolean!` ## `startTx` -### `startTx` `args` +**args:** -`id: ID!` +`id`: `ID!` -`txJson: String!` +`txJson`: `String!` returns `RunResult!` ## `continueTx` -### `continueTx` `args` +**args:** -`id: ID!` +`id`: `ID!` returns `RunResult!` @@ -85,20 +85,20 @@ A mutation that spins up a new temporary node from the current state and emulate It returns a [`[Receipt!]!`](/docs/reference/objects/#receipt) for the emulated transaction. You can optionally use UTXO validation. -### `dryRun` `args` +**args:** `tx`: [`HexString!`](/docs/reference/scalars/#hexstring) The transaction hex string. -`utxoValidation: Boolean`: +`utxoValidation`: `Boolean`: Whether or not to use UTXO validation. ## `produceBlocks` A mutation that produces blocks, that can be used for testing that requires block advancement. Returns a [`U32!`](/docs/reference/scalars/#u32). -### `produceBlocks` `args` +**args:** `startTimestamp`: [`Tai64Timestamp!`](/docs/reference/scalars/#tai64timestamp) @@ -112,8 +112,8 @@ The number of blocks to produce. A mutation that submits transaction to the transaction pool and returns a [`Transaction!`](/docs/reference/objects/#transaction). -### `submit` `args` +**args:** -`tx:` [`HexString!`](/docs/reference/scalars/#hexstring) +`tx`: [`HexString!`](/docs/reference/scalars/#hexstring) The transaction hex string. diff --git a/scripts/coverage/utils.mjs b/scripts/coverage/utils.mjs index 57f4503..8d772d8 100644 --- a/scripts/coverage/utils.mjs +++ b/scripts/coverage/utils.mjs @@ -199,7 +199,7 @@ export function checkIfEqual(a, b) { const bVal = b[index]; const isEqual = value.id === bVal.id && value.name === bVal.name; if (!isEqual) { - console.log('!!!!!!NOT EQUAL!!!!'); + console.log('*********NOT EQUAL*********'); console.log('VALUE A:', value); console.log('VALUE B:', bVal); } From 4095f08c4da7542db7a7919487f8907059b749b6 Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Sun, 28 Jan 2024 10:56:39 -0700 Subject: [PATCH 10/13] fix --- docs/reference/objects.mdx | 12 ++++++------ docs/reference/unions.mdx | 2 +- spell-check-custom-words.txt | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/reference/objects.mdx b/docs/reference/objects.mdx index e9bc705..7f38ccc 100644 --- a/docs/reference/objects.mdx +++ b/docs/reference/objects.mdx @@ -185,15 +185,15 @@ The consensus parameters used for validating blocks. **fields:** -`txParams`: [`TxParameters!`](#TxParameters) +`txParams`: [`TxParameters!`](#txparameters) The allowed parameters of transactions -`predicateParams`: [`PredicateParameters!`](#PredicateParameters) +`predicateParams`: [`PredicateParameters!`](#predicateparameters) The allowed parameters of predicates -`scriptParams`: [`ScriptParameters!`](#ScriptParameters) +`scriptParams`: [`ScriptParameters!`](#scriptparameters) The allowed parameters of scripts @@ -1221,7 +1221,7 @@ The last reported height of the peer node. `lastHeartbeatMs`: [`U64!`](/docs/reference/scalars/#u64) -The time of the last heartbeat from this peer node in unix epoch time milliseconds. +The time of the last heartbeat from this peer node in Unix epoch time milliseconds. `appScore`: `Float!` @@ -1289,7 +1289,7 @@ The maximum length of predicate data. `maxGasPerPredicate`: [`U64!`](/docs/reference/scalars/#u64) -The maxiumum amount of gas allowed for a predicate. +The maximum amount of gas allowed for a predicate. `maxMessageDataLength`: [`U64!`](/docs/reference/scalars/#u64) @@ -1647,7 +1647,7 @@ The maximum number of witnesses allowed for a transaction. `maxGasPerTx`: [`U64!`](/docs/reference/scalars/#u64) -The maximum amoutn of gas allowed for a transaction. +The maximum amount of gas allowed for a transaction. `maxSize`: [`U64!`](/docs/reference/scalars/#u64) diff --git a/docs/reference/unions.mdx b/docs/reference/unions.mdx index e4e21b8..6fa9af4 100644 --- a/docs/reference/unions.mdx +++ b/docs/reference/unions.mdx @@ -58,7 +58,7 @@ An output type for a transaction. **Types:** [`CoinOutput`](/docs/reference/objects/#coinoutput): Indicates coins -were forwarded from one address to another. +were forwarded from one address to another. Can be used during transaction creation when the recipient, asset, and amount is known. [`ContractOutput`](/docs/reference/objects/#contractoutput): diff --git a/spell-check-custom-words.txt b/spell-check-custom-words.txt index 854dd9f..cf3e927 100644 --- a/spell-check-custom-words.txt +++ b/spell-check-custom-words.txt @@ -74,4 +74,5 @@ mempool EOA args breakpoint -PeerInfo \ No newline at end of file +PeerInfo +Unix \ No newline at end of file From 42158611919073a76e41d8718b83b6815d6f52cc Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Mon, 29 Jan 2024 08:40:16 -0700 Subject: [PATCH 11/13] update mutations --- docs/reference/mutations.mdx | 67 ++++++++++++++++++++++++++---------- docs/reference/objects.mdx | 1 + 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/docs/reference/mutations.mdx b/docs/reference/mutations.mdx index 01b6439..d8f4f5d 100644 --- a/docs/reference/mutations.mdx +++ b/docs/reference/mutations.mdx @@ -3,86 +3,113 @@ title: Mutations category: Reference --- -{/*TODO: Finish this mutation*/} - # Mutations ## `startSession` -**args:** - -`id`: `ID!` - -returns `Boolean!` +Initialize a new debugger session, returning its `ID`. +A new VM instance is spawned for each session. +The session is run in a separate database transaction, +on top of the most recent node state. ## `endSession` +End a debugger session. +Returns a `Boolean!` indicating whether the session was successfully ended. + **args:** `id`: `ID!` -returns `Boolean!` +The session ID. ## `reset` +Reset the VM instance to the initial state. +Returns a `Boolean!` indicating whether the VM instance was successfully reset. + **args:** `id`: `ID!` -returns `Boolean!` +The session ID. ## `execute` +Execute a single `fuel-asm` instruction. +Returns a `Boolean!` indicating whether the instruction was successfully executed. + **args:** `id`: `ID!` +The session ID. + `op`: `String!` -returns `Boolean!` +The `fuel-asm` instruction to execute. ## `setSingleStepping` +Set single-stepping mode for the VM instance. +Returns a `Boolean!` indicating whether the mutation successfully executed. + **args:** `id`: `ID!` +The session ID. + `enable`: `boolean` -returns `Boolean!` +Whether to enable single-stepping mode. ## `setBreakpoint` +Set a breakpoint for a VM instance. +Returns a `Boolean!` indicating whether the breakpoint was successfully set. + **args:** `id`: `ID!` +The session ID. + `breakpoint`: [`Breakpoint!`](/docs/reference/objects/#breakpoint) -returns `Boolean!` +The breakpoint to set. ## `startTx` +Run a single transaction in given session until it hits a breakpoint or completes. +Returns a `RunResult!`. + **args:** `id`: `ID!` +The session ID. + `txJson`: `String!` -returns `RunResult!` +The transaction JSON string. ## `continueTx` +Resume execution of the VM instance after a breakpoint. +Runs until the next breakpoint or until the transaction completes. +Returns a `RunResult!`. + **args:** `id`: `ID!` -returns `RunResult!` +The session ID. ## `dryRun` -A mutation that spins up a new temporary node from the current state and emulates a given transaction. -It returns a [`[Receipt!]!`](/docs/reference/objects/#receipt) for the emulated transaction. +Spin up a new temporary node from the current state and emulate a given transaction. +Returns a [`[Receipt!]!`](/docs/reference/objects/#receipt) for the emulated transaction. You can optionally use UTXO validation. **args:** @@ -91,12 +118,13 @@ You can optionally use UTXO validation. The transaction hex string. -`utxoValidation`: `Boolean`: +`utxoValidation`: `Boolean` Whether or not to use UTXO validation. ## `produceBlocks` -A mutation that produces blocks, that can be used for testing that requires block advancement. Returns a [`U32!`](/docs/reference/scalars/#u32). +Produce blocks that can be used for testing that requires block advancement. +Returns a [`U32!`](/docs/reference/scalars/#u32). **args:** @@ -110,7 +138,8 @@ The number of blocks to produce. ## `submit` -A mutation that submits transaction to the transaction pool and returns a [`Transaction!`](/docs/reference/objects/#transaction). +Submit a transaction to the transaction pool. +Returns a [`Transaction!`](/docs/reference/objects/#transaction). **args:** diff --git a/docs/reference/objects.mdx b/docs/reference/objects.mdx index 7f38ccc..b782cba 100644 --- a/docs/reference/objects.mdx +++ b/docs/reference/objects.mdx @@ -58,6 +58,7 @@ An array of transactions included in the block. ## `Breakpoint` A breakpoint during debugging. +Defined as a tuple of a contract ID and relative `pc` offset inside it. **fields:** From ecbb2280a4bc09a53ae83eaec3acd3218a5be025 Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Mon, 29 Jan 2024 08:43:49 -0700 Subject: [PATCH 12/13] fix lint --- docs/reference/mutations.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/mutations.mdx b/docs/reference/mutations.mdx index d8f4f5d..90a2145 100644 --- a/docs/reference/mutations.mdx +++ b/docs/reference/mutations.mdx @@ -9,7 +9,7 @@ category: Reference Initialize a new debugger session, returning its `ID`. A new VM instance is spawned for each session. -The session is run in a separate database transaction, +The session is run in a separate database transaction, on top of the most recent node state. ## `endSession` From c35b609c95dd5eb035a37d0350771ba8bda15890 Mon Sep 17 00:00:00 2001 From: sarahschwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:12:11 -0700 Subject: [PATCH 13/13] refactor query examples, address review --- docs/recipes.mdx | 351 +------------------------------------ docs/reference/enums.mdx | 2 +- docs/reference/scalars.mdx | 6 +- examples/query.tsx | 44 +++-- 4 files changed, 40 insertions(+), 363 deletions(-) diff --git a/docs/recipes.mdx b/docs/recipes.mdx index 026ddf3..da7a825 100644 --- a/docs/recipes.mdx +++ b/docs/recipes.mdx @@ -23,28 +23,8 @@ Click the "TypeScript", "Apollo Client", or "urql" buttons to see code examples. ## Get an asset balance of an address -```graphql -query Balance($address: Address, $assetId: AssetId) { - balance(owner: $address, assetId: $assetId) { - owner - amount - assetId - } -} -``` - -Variables: - -```json -{ - "address": "0xf65d6448a273b531ee942c133bb91a6f904c7d7f3104cdaf6b9f7f50d3518871", - "assetId": "0x0000000000000000000000000000000000000000000000000000000000000000" -} -``` - -{' '} - + <> + {props.query && ( <> - +
+            {props.query}
+          
- {resp && ( + {props.args && Object.keys(props.args).length > 0 && ( <> -
Response:
- + Variables: +
+                
+                  {JSON.stringify(props.args, null, 2)}
+                
+              
)} -
- + )} + + + + <> + + + {resp && ( + <> +
Response:
+ + + )} + +
+
+ ); }