Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indexer template and release #260

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ All notable changes to the create-aptos-dapp tool will be captured in this file.

# Unreleased

# 0.0.36 (2024-10-28)

- Remove `uniqueHolders` from NFT minting dapp template due to inefficient indexer query
- Upgrade to the new Irys SDK
- Fix indexer template not working due to address padding and wrong module name

# 0.0.35 (2024-10-23)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "create-aptos-dapp",
"description": "a starter kit for dapp developers to easily bootstrap a dapp on the Aptos network",
"version": "0.0.35",
"version": "0.0.36",
"license": "Apache-2.0",
"author": "aptoslabs.com",
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions templates/custom-indexer-template/_gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ pnpm-lock.yaml
*.sw?

.next

target
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use aptos_indexer_processor_sdk::{
},
traits::{async_step::AsyncRunType, AsyncStep, NamedStep, Processable},
types::transaction_context::TransactionContext,
utils::errors::ProcessorError,
utils::{convert::standardize_address, errors::ProcessorError},
};
use async_trait::async_trait;
use rayon::prelude::*;
Expand Down Expand Up @@ -126,12 +126,18 @@ pub enum ContractEvent {

impl ContractEvent {
fn from_event(contract_address: &str, event_idx: usize, event: &EventPB) -> Option<Self> {
let t: &str = event.type_str.as_ref();
// use standardize_address to pad the address in event type before processing
let parts = event.type_str.split("::").collect::<Vec<_>>();
let t = standardize_address(parts[0]) + "::" + parts[1] + "::" + parts[2];
let should_include = t.starts_with(contract_address);

if should_include {
if t.starts_with(
format!("{}::message_board::CreateMessageEvent", contract_address).as_str(),
format!(
"{}::custom_indexer_ex_message_board::CreateMessageEvent",
contract_address
)
.as_str(),
) {
println!("CreateMessageEvent {}", event.data.as_str());
let create_message_event_on_chain: CreateMessageEventOnChain =
Expand All @@ -145,7 +151,11 @@ impl ContractEvent {
create_message_event_on_chain.to_db_message(),
))
} else if t.starts_with(
format!("{}::message_board::UpdateMessageEvent", contract_address).as_str(),
format!(
"{}::custom_indexer_ex_message_board::UpdateMessageEvent",
contract_address
)
.as_str(),
) {
println!("UpdateMessageEvent {}", event.data.as_str());
let update_message_event_on_chain: UpdateMessageEventOnChain =
Expand Down Expand Up @@ -196,10 +206,12 @@ impl ContractUpgradeChange {
.for_each(|change| match change.change.as_ref() {
Some(change) => match change {
Change::WriteModule(write_module_change) => {
if write_module_change.address == contract_address {
if standardize_address(write_module_change.address.as_str())
== contract_address
{
raw_module_changes.insert(
(
write_module_change.address.clone(),
standardize_address(write_module_change.address.as_str()),
write_module_change
.data
.clone()
Expand All @@ -218,7 +230,8 @@ impl ContractUpgradeChange {
}
}
Change::WriteResource(write_resource_change) => {
if write_resource_change.address == contract_address
if standardize_address(write_resource_change.address.as_str())
== contract_address
&& write_resource_change.type_str == "0x1::code::PackageRegistry"
{
let package_upgrade: PackageUpgradeChangeOnChain =
Expand Down
Loading