-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
136 additions
and
65 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
common/changes/@subsquid/substrate-data-raw/master_2024-01-04-17-13.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@subsquid/substrate-data-raw", | ||
"comment": "allow `block.events` to be null", | ||
"type": "minor" | ||
} | ||
], | ||
"packageName": "@subsquid/substrate-data-raw" | ||
} |
15 changes: 15 additions & 0 deletions
15
common/changes/@subsquid/substrate-data/master_2024-01-04-17-13.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@subsquid/substrate-data", | ||
"comment": "fix genesis block fetch error by allowing `null` event storage values", | ||
"type": "patch" | ||
}, | ||
{ | ||
"packageName": "@subsquid/substrate-data", | ||
"comment": "fix: sometimes block validator is not set", | ||
"type": "patch" | ||
} | ||
], | ||
"packageName": "@subsquid/substrate-data" | ||
} |
10 changes: 10 additions & 0 deletions
10
common/changes/@subsquid/substrate-dump/master_2024-01-04-17-13.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@subsquid/substrate-dump", | ||
"comment": "fix genesis block fetch error by allowing `null` event storage values", | ||
"type": "patch" | ||
} | ||
], | ||
"packageName": "@subsquid/substrate-dump" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {Rpc} from '@subsquid/substrate-data-raw' | ||
import {Bytes, Runtime} from '@subsquid/substrate-runtime' | ||
import {getNameHash} from '@subsquid/substrate-runtime/lib/runtime/storage' | ||
import {parseQualifiedName} from '@subsquid/substrate-runtime/lib/runtime/util' | ||
import {array, bytes, GetType, numeric, Type} from '@subsquid/substrate-runtime/lib/sts' | ||
import {assertNotNull, def} from '@subsquid/util-internal' | ||
import {RawBlock} from './interfaces/data-raw' | ||
import {assertStorage} from './types/util' | ||
|
||
|
||
class ScalarStorage<T extends Type> { | ||
constructor(private name: string, private type: T) {} | ||
|
||
assert(runtime: Runtime | RawBlock): void { | ||
assertStorage(getRuntime(runtime), this.name, ['Default', 'Required'], [], this.type) | ||
} | ||
|
||
check(runtime: Runtime | RawBlock): boolean { | ||
return getRuntime(runtime).checkStorageType(this.name, ['Default', 'Required'], [], this.type) | ||
} | ||
|
||
isDefined(runtime: Runtime | RawBlock): boolean { | ||
return getRuntime(runtime).hasStorageItem(this.name) | ||
} | ||
|
||
@def | ||
key(): Bytes { | ||
let [pallet, name] = parseQualifiedName(this.name) | ||
return getNameHash(pallet) + getNameHash(name).slice(2) | ||
} | ||
|
||
async get(rpc: Rpc, block: RawBlock): Promise<GetType<T> | undefined> { | ||
this.assert(block) | ||
let value = await rpc.getStorage(this.key(), block.hash) | ||
if (value === undefined) return | ||
return this.decode(block, value) | ||
} | ||
|
||
decode(runtime: RawBlock | Runtime, value: Bytes | null): GetType<T> { | ||
this.assert(runtime) | ||
return getRuntime(runtime).decodeStorageValue(this.name, value) | ||
} | ||
} | ||
|
||
|
||
function getRuntime(blockOrRuntime: RawBlock | Runtime): Runtime { | ||
if (blockOrRuntime instanceof Runtime) return blockOrRuntime | ||
return assertNotNull(blockOrRuntime.runtime) | ||
} | ||
|
||
|
||
export const STORAGE = { | ||
nextFeeMultiplier: new ScalarStorage('TransactionPayment.NextFeeMultiplier', numeric()), | ||
sessionIndex: new ScalarStorage('Session.CurrentIndex', numeric()), | ||
validators: new ScalarStorage('Session.Validators', array(bytes())) | ||
} |
This file was deleted.
Oops, something went wrong.