Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
},
{
files: ['*.{ts,tsx}'],
excludedFiles: ['**/*.{md,mdx}/*.{ts,tsx}'],
parserOptions: {
project: 'tsconfig.json',
},
Expand All @@ -23,6 +24,32 @@ module.exports = {
rules: {
'mdx/remark': 'error',
},
settings: {
'mdx/code-blocks': true,
},
},
{
files: ['**/*.{md,mdx}/*.{ts,tsx}'],
rules: {
// Disables rules that requires type information
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/prefer-includes': 'off',
'@typescript-eslint/prefer-return-this-type': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
// Disable rules for code-blocks
'no-restricted-globals': 'off',
},
},
],
}
93 changes: 46 additions & 47 deletions website/pages/en/cookbook/near.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,64 +102,63 @@ The handlers for processing events are written in [AssemblyScript](https://www.a

NEAR indexing introduces NEAR-specific data types to the [AssemblyScript API](/developing/assemblyscript-api).

```typescript

```ts
class ExecutionOutcome {
gasBurnt: u64,
blockHash: Bytes,
id: Bytes,
logs: Array<string>,
receiptIds: Array<Bytes>,
tokensBurnt: BigInt,
executorId: string,
}
gasBurnt: u64
blockHash: Bytes
id: Bytes
logs: string[]
receiptIds: Bytes[]
tokensBurnt: bigint
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typescript-eslint suggests replacing BigInt with bigint
image

executorId: string
}

class ActionReceipt {
predecessorId: string,
receiverId: string,
id: CryptoHash,
signerId: string,
gasPrice: BigInt,
outputDataReceivers: Array<DataReceiver>,
inputDataIds: Array<CryptoHash>,
actions: Array<ActionValue>,
}
predecessorId: string
receiverId: string
id: CryptoHash
signerId: string
gasPrice: bigint
outputDataReceivers: DataReceiver[]
inputDataIds: CryptoHash[]
actions: ActionValue[]
}

class BlockHeader {
height: u64,
prevHeight: u64,// Always zero when version < V3
epochId: Bytes,
nextEpochId: Bytes,
chunksIncluded: u64,
hash: Bytes,
prevHash: Bytes,
timestampNanosec: u64,
randomValue: Bytes,
gasPrice: BigInt,
totalSupply: BigInt,
latestProtocolVersion: u32,
}
height: u64
prevHeight: u64 // Always zero when version < V3
epochId: Bytes
nextEpochId: Bytes
chunksIncluded: u64
hash: Bytes
prevHash: Bytes
timestampNanosec: u64
randomValue: Bytes
gasPrice: bigint
totalSupply: bigint
latestProtocolVersion: u32
}

class ChunkHeader {
gasUsed: u64,
gasLimit: u64,
shardId: u64,
chunkHash: Bytes,
prevBlockHash: Bytes,
balanceBurnt: BigInt,
}
gasUsed: u64
gasLimit: u64
shardId: u64
chunkHash: Bytes
prevBlockHash: Bytes
balanceBurnt: bigint
}

class Block {
author: string,
header: BlockHeader,
chunks: Array<ChunkHeader>,
}
author: string
header: BlockHeader
chunks: ChunkHeader[]
}

class ReceiptWithOutcome {
outcome: ExecutionOutcome,
receipt: ActionReceipt,
block: Block,
}
outcome: ExecutionOutcome
receipt: ActionReceipt
block: Block
}
```

These types are passed to block & receipt handlers:
Expand Down
6 changes: 3 additions & 3 deletions website/pages/en/cookbook/subgraph-debug-forking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ To stay focused on subgraph debugging, let's keep things simple and run along wi

Here are the handlers defined for indexing `Gravatar`s, with no bugs whatsoever:

```tsx
```ts
export function handleNewGravatar(event: NewGravatar): void {
let gravatar = new Gravatar(event.params.id.toHex().toString())
const gravatar = new Gravatar(event.params.id.toHex().toString())
gravatar.owner = event.params.owner
gravatar.displayName = event.params.displayName
gravatar.imageUrl = event.params.imageUrl
gravatar.save()
}

export function handleUpdatedGravatar(event: UpdatedGravatar): void {
let gravatar = Gravatar.load(event.params.id.toI32().toString())
const gravatar = Gravatar.load(event.params.id.toI32().toString())
if (gravatar == null) {
log.critical('Gravatar not found!', [])
return
Expand Down
Loading