@aresrpg/sui-checkpoint-reader
Advanced tools
Comparing version
{ | ||
"name": "@aresrpg/sui-checkpoint-reader", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -34,15 +34,15 @@ <p align=center> | ||
```js | ||
import { read_checkpoints } from '@aresrpg/sui-checkpoint-reader'; | ||
import { read_checkpoints } from '@aresrpg/sui-checkpoint-reader' | ||
async function get_remote_checkpoint(num) { | ||
const response = await fetch(`https://checkpoints.testnet.sui.io/${num}.chk`); | ||
const buffer = await response.arrayBuffer(); | ||
return buffer; | ||
const response = await fetch(`https://checkpoints.testnet.sui.io/${num}.chk`) | ||
const buffer = await response.arrayBuffer() | ||
return buffer | ||
} | ||
async function process_checkpoint(checkpoint, index) { | ||
console.log('[indexer] process_checkpoint:', index); | ||
console.log('[indexer] process_checkpoint:', index) | ||
} | ||
const known_types = {}; | ||
const known_types = {} | ||
@@ -58,3 +58,3 @@ await read_checkpoints({ | ||
process_checkpoint, // Function to process each checkpoint | ||
}); | ||
}) | ||
``` | ||
@@ -85,15 +85,15 @@ | ||
```js | ||
import { read_checkpoints } from '@aresrpg/sui-checkpoint-reader'; | ||
import { read_checkpoints } from '@aresrpg/sui-checkpoint-reader' | ||
async function get_remote_checkpoint(num) { | ||
const response = await fetch(`https://checkpoints.testnet.sui.io/${num}.chk`); | ||
const buffer = await response.arrayBuffer(); | ||
return buffer; | ||
const response = await fetch(`https://checkpoints.testnet.sui.io/${num}.chk`) | ||
const buffer = await response.arrayBuffer() | ||
return buffer | ||
} | ||
async function process_checkpoint(checkpoint, index) { | ||
console.log('[indexer] process_checkpoint:', index); | ||
console.log('[indexer] process_checkpoint:', index) | ||
} | ||
const known_types = {}; | ||
const known_types = {} | ||
@@ -106,3 +106,3 @@ await read_checkpoints({ | ||
process_checkpoint, | ||
}); | ||
}) | ||
``` | ||
@@ -109,0 +109,0 @@ |
149
src/index.js
@@ -263,12 +263,4 @@ import { setInterval, setTimeout } from 'timers/promises' | ||
// TODO | ||
const GenesisObject = bcs.enum('GenesisObject', {}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L191-L193 | ||
const GenesisTransaction = bcs.struct('GenesisTransaction', { | ||
objects: bcs.vector(GenesisObject), | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/messages_consensus.rs#L28-L35 | ||
const ConsensusCommitPrologue = bcs.enum('ConsensusCommitPrologue', { | ||
const ConsensusCommitPrologue = bcs.struct('ConsensusCommitPrologue', { | ||
epoch: bcs.u64(), | ||
@@ -279,62 +271,63 @@ round: bcs.u64(), | ||
// TODO | ||
const AuthenticatorStateUpdate = bcs.enum('AuthenticatorStateUpdate', {}) | ||
const JwkId = bcs.struct('JwkId', { | ||
iss: bcs.string(), | ||
kid: bcs.string(), | ||
}) | ||
// TODO | ||
const EndOfEpochTransactionKind = bcs.enum('EndOfEpochTransactionKind', {}) | ||
const JWK = bcs.struct('JWK', { | ||
kty: bcs.string(), | ||
e: bcs.string(), | ||
n: bcs.string(), | ||
alg: bcs.string(), | ||
}) | ||
// TODO | ||
const RandomnessStateUpdate = bcs.enum('RandomnessStateUpdate', {}) | ||
const ActiveJwk = bcs.struct('ActiveJwk', { | ||
jwk_id: JwkId, | ||
jwk: JWK, | ||
epoch: EpochId, | ||
}) | ||
// TODO | ||
const ConsensusCommitDigest = Digest | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/messages_consensus.rs#L38-L47 | ||
const ConsensusCommitPrologueV2 = bcs.struct('ConsensusCommitPrologueV2', { | ||
epoch: bcs.u64(), | ||
const AuthenticatorStateUpdate = bcs.enum('AuthenticatorStateUpdate', { | ||
epoch: EpochId, | ||
round: bcs.u64(), | ||
commit_timestamp_ms: CheckpointTimestamp, | ||
consensus_commit_digest: ConsensusCommitDigest, | ||
new_active_jwks: bcs.vector(ActiveJwk), | ||
authenticator_obj_initial_shared_version: SequenceNumber, | ||
}) | ||
const ConsensusCommitPrologueV3 = bcs.enum('ConsensusCommitPrologueV3', {}) | ||
const AuthenticatorStateExpire = bcs.struct('AuthenticatorStateExpire', { | ||
min_epoch: EpochId, | ||
authenticator_obj_initial_shared_version: SequenceNumber, | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L266-L295 | ||
const TransactionKind = bcs.enum('TransactionKind', { | ||
ProgrammableTransaction, | ||
const ChainIdentifier = CheckpointDigest | ||
const EndOfEpochTransactionKind = bcs.enum('EndOfEpochTransactionKind', { | ||
ChangeEpoch, | ||
Genesis: GenesisTransaction, | ||
ConsensusCommitPrologue, | ||
AuthenticatorStateUpdate, | ||
EndOfEpochTransaction: bcs.vector(EndOfEpochTransactionKind), | ||
RandomnessStateUpdate, | ||
ConsensusCommitPrologueV2, | ||
ConsensusCommitPrologueV3, | ||
AuthenticatorStateCreate: null, | ||
AuthenticatorStateExpire, | ||
RandomnessStateCreate: null, | ||
DenyListStateCreate: null, | ||
BridgeStateCreate: ChainIdentifier, | ||
BridgeCommitteeInit: SequenceNumber, | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L1503-L1508 | ||
const TransactionDataV1 = bcs.struct('TransactionDataV1', { | ||
kind: TransactionKind, | ||
sender: SuiAddress, | ||
gas_data: GasData, | ||
expiration: TransactionExpiration, | ||
const RandomnessStateUpdate = bcs.struct('RandomnessStateUpdate', { | ||
epoch: EpochId, | ||
randomness_round: bcs.u64(), | ||
random_bytes: bcs.vector(bcs.u8()), | ||
randomness_obj_initial_shared_version: SequenceNumber, | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L1496-L1500 | ||
const TransactionData = bcs.enum('TransactionData', { | ||
V1: TransactionDataV1, | ||
}) | ||
const ConsensusCommitDigest = Digest | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L2108-L2114 | ||
const SenderSignedTransaction = bcs.struct('SenderSignedTransaction', { | ||
intent_message: IntentMessage(TransactionData), | ||
tx_signatures: bcs.vector(GenericSignature), | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/messages_consensus.rs#L38-L47 | ||
const ConsensusCommitPrologueV2 = bcs.struct('ConsensusCommitPrologueV2', { | ||
epoch: bcs.u64(), | ||
round: bcs.u64(), | ||
commit_timestamp_ms: CheckpointTimestamp, | ||
consensus_commit_digest: ConsensusCommitDigest, | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L2105 | ||
const SenderSignedData = bcs.vector(SenderSignedTransaction) | ||
const ConsensusCommitPrologueV3 = bcs.enum('ConsensusCommitPrologueV3', {}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L2630 | ||
const Transaction = Envelope('Transaction', SenderSignedData, EmptySignInfo) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/base_types.rs#L169-L181 | ||
@@ -393,2 +386,27 @@ const MoveObjectType = bcs.enum('MoveObjectType', { | ||
const GenesisObject = bcs.enum('GenesisObject', { | ||
RawObject: bcs.struct('RawObject', { | ||
data: Data, | ||
owner: Owner, | ||
}), | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L191-L193 | ||
const GenesisTransaction = bcs.struct('GenesisTransaction', { | ||
objects: bcs.vector(GenesisObject), | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L266-L295 | ||
const TransactionKind = bcs.enum('TransactionKind', { | ||
ProgrammableTransaction, | ||
ChangeEpoch, | ||
Genesis: GenesisTransaction, | ||
ConsensusCommitPrologue, | ||
AuthenticatorStateUpdate, | ||
EndOfEpochTransaction: bcs.vector(EndOfEpochTransactionKind), | ||
RandomnessStateUpdate, | ||
ConsensusCommitPrologueV2, | ||
ConsensusCommitPrologueV3, | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-graphql-rpc/src/types/transaction_block_effects.rs#L78-L83 | ||
@@ -508,2 +526,27 @@ const ExecutionStatus = bcs.enum('ExecutionStatus', { | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L1503-L1508 | ||
const TransactionDataV1 = bcs.struct('TransactionDataV1', { | ||
kind: TransactionKind, | ||
sender: SuiAddress, | ||
gas_data: GasData, | ||
expiration: TransactionExpiration, | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L1496-L1500 | ||
const TransactionData = bcs.enum('TransactionData', { | ||
V1: TransactionDataV1, | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L2108-L2114 | ||
const SenderSignedTransaction = bcs.struct('SenderSignedTransaction', { | ||
intent_message: IntentMessage(TransactionData), | ||
tx_signatures: bcs.vector(GenericSignature), | ||
}) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L2105 | ||
const SenderSignedData = bcs.vector(SenderSignedTransaction) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/transaction.rs#L2630 | ||
const Transaction = Envelope('Transaction', SenderSignedData, EmptySignInfo) | ||
// https://github.com/MystenLabs/sui/blob/testnet-v1.28.3/crates/sui-types/src/full_checkpoint_content.rs#L45-L56 | ||
@@ -510,0 +553,0 @@ const CheckpointTransaction = bcs.struct('CheckpointTransaction', { |
46390
2.26%969
4.08%