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

docs: Add On-chain tracking page #671

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

germartinez
Copy link
Member

@germartinez germartinez commented Jan 10, 2025

Context

This PR:

  • Adds a new page for on-chain tracking.
  • Points to the on-chain tracking page from Protocol Kit and Relay Kit guides.
  • Removes on-chain tracking sections in existing guides and points to the new page.

@germartinez germartinez changed the title docs: Add On.chain tracking docs: Add On-chain tracking page Jan 10, 2025
Copy link

github-actions bot commented Jan 10, 2025

Branch preview

✅ Deployed successfully in branch deployment:

https://onchain_tracking--docs.review.5afe.dev

Copy link

github-actions bot commented Jan 10, 2025

Overall readability score: 31.23 (🔴 -0.08)

File Readability
getOnchainIdentifier.mdx 6.11 (-)
onchain-tracking.mdx 35.03 (-)
execute-transactions.mdx 40.73 (🔴 -0.23)
multichain-safe-deployment.mdx 34.71 (🟢 +0.7)
safe-deployment.mdx 25.51 (🟢 +1.5)
4337-safe-sdk.mdx 31.71 (🔴 -4.85)
View detailed metrics

🟢 - Shows an increase in readability
🔴 - Shows a decrease in readability

File Readability FRE GF ARI CLI DCRS
getOnchainIdentifier.mdx 6.11 0 16.84 22 19 10.25
  - - - - - -
onchain-tracking.mdx 35.03 29.48 14.03 18.9 14.28 7.74
  - - - - - -
execute-transactions.mdx 40.73 40.92 14.87 18.9 11.56 7.3
  🔴 -0.23 🟢 +0.1 🟢 +0.09 🔴 -0.1 🔴 -0.23 🟢 +0.02
multichain-safe-deployment.mdx 34.71 34.39 14.83 20 13.18 7.65
  🟢 +0.7 🔴 -7.14 🟢 +0.3 🟢 +0.7 🟢 +0.18 🟢 +0.03
safe-deployment.mdx 25.51 32.46 16.52 21.7 13.94 8.41
  🟢 +1.5 🟢 +2.33 🟢 +0.49 🟢 +0.3 🔴 -0.18 🟢 +0.03
4337-safe-sdk.mdx 31.71 36.76 17.32 20.6 11.44 7.87
  🔴 -4.85 🔴 -2.44 🔴 -1.11 🔴 -1.2 🔴 -0.11 🔴 -0.2

Averages:

  Readability FRE GF ARI CLI DCRS
Average 31.23 27.18 13.72 17.46 15.74 8.98
  🔴 -0.08 🔴 -0.1 🔴 -0.01 🔴 -0.02 🔴 -0.01 🟢 +0
View metric targets
Metric Range Ideal score
Flesch Reading Ease 100 (very easy read) to 0 (extremely difficult read) 60
Gunning Fog 6 (very easy read) to 17 (extremely difficult read) 8 or less
Auto. Read. Index 6 (very easy read) to 14 (extremely difficult read) 8 or less
Coleman Liau Index 6 (very easy read) to 17 (extremely difficult read) 8 or less
Dale-Chall Readability 4.9 (very easy read) to 9.9 (extremely difficult read) 6.9 or less


### Track Safe deployments

Safe deployments can be tracked by assigning an on-chain identifier to the [`paymentReceiver`](../reference-smart-account/setup/setup.mdx#paymentreceiver) or [`saltNonce`](https://github.com/safe-global/safe-smart-account/blob/main/contracts/proxies/SafeProxyFactory.sol#L55) properties during the Safe configuration and deployment.
Copy link
Contributor

Choose a reason for hiding this comment

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

The on-chain identifier will always be appended to the end of the data field of the deployment transaction, both for Safe deployments and Safe transactions. Using the paymentReceiver or saltNonce was an initial idea, but it's not part of the final implementation.

Copy link
Member Author

@germartinez germartinez Jan 13, 2025

Choose a reason for hiding this comment

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

Yes, I know that is how the SDK works, but here it refers about the different options that exist for people using onchain tracking without the SDK. This sections has two paragrap: the initial one that shows the different options and the second one that shows how the SDK works. I will make it more explicit that the SDK only uses data.

import Safe, { OnchainAnalyticsProps } from '@safe-global/protocol-kit'

const onchainAnalytics: OnchainAnalyticsProps = {
project: 'YOUR_PROJECT_NAME'
Copy link
Contributor

Choose a reason for hiding this comment

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

How about we add a comment like this to help developers better understand? It clarifies that the project field is mandatory and should remain consistent for each project:

project: 'YOUR_PROJECT_NAME' // Required. Always use the same value for your project, e.g., 'Cow Swap' or 'AAVE'.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. I will make a reference that this field is linked to the Project hash explained in the format section.

@DaniSomoza
Copy link
Contributor

Should we include the new getOnchainIdentifier function in the protocol-kit reference?

@DaniSomoza
Copy link
Contributor

I think that some external projects were interested in implementing their own solution compatible with our onchain identifier.

Should we add a simple entry in the documentation to guide them?

We could explain how to use keccak256 to generate their identifiers with the correct values. We can provide our generateOnChainIdentifier function as an example:

function generateOnChainIdentifier({
  project,
  platform = 'Web',
  tool,
  toolVersion
}: OnChainIdentifierParamsType): string {
  const identifierPrefix = '5afe'
  const identifierVersion = '00' // first version
  const projectHash = generateHash(project, 20) // Take the last 20 bytes
  const platformHash = generateHash(platform, 3) // Take the last 3 bytes
  const toolHash = generateHash(tool, 3) // Take the last 3 bytes
  const toolVersionHash = generateHash(toolVersion, 3) // Take the last 3 bytes

  return `${identifierPrefix}${identifierVersion}${projectHash}${platformHash}${toolHash}${toolVersionHash}`
}

export function generateHash(input: string, size: number): string {
  const fullHash = keccak256(toHex(input))
  return toHex(fullHash.slice(-size)).replace('0x', '') // Take the last X bytes
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants