-
During testing, we found out a problem: events can include abridged addresses, they lack the leading / padding zeros. The problem is that the GraphQL API doesn't recognize such addresses. As an example, see TransferEvent in this transaction. The object in TransferEvent there is So this request for token data doesn't return any results:
However if I set |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Unfortunately this is a deficiency on our side. For legacy reasons, some representations of account addresses are not AIP-40 compliant and therefore return addresses without padding zeroes (abridged as you say). One big culprit is the JSON representation of a Move resource, leading zeroes are dropped. All you can do is normalize the address client side. For example, in Typescript with the TS SDK, with a function like this: import { AccountAddress } from '@aptos-labs/ts-sdk';
export function normalizeAddress(address: string) {
return AccountAddress.from(address).toStringLong();
} Or just something like this: export function normalizeAddress(address: string): string {
// Check if the input address starts with "0x"
if (address.startsWith("0x")) {
// Remove the leading "0x" before normalizing
address = address.substring(2);
}
// Return the normalized address with a "0x" prefix, and ensure it is 64 characters long
return "0x" + address.padStart(64, "0");
} |
Beta Was this translation helpful? Give feedback.
Unfortunately this is a deficiency on our side. For legacy reasons, some representations of account addresses are not AIP-40 compliant and therefore return addresses without padding zeroes (abridged as you say). One big culprit is the JSON representation of a Move resource, leading zeroes are dropped.
All you can do is normalize the address client side. For example, in Typescript with the TS SDK, with a function like this:
Or just something like this: