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

[Dashboard | SDK] Feature: Ref values for address params in publish #5360

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

kumaryash90
Copy link
Member

@kumaryash90 kumaryash90 commented Nov 8, 2024

Problem solved

https://linear.app/thirdweb/project/[contract-tooling]-deployment-publish-flow-revamp-0194e04e2a84/overview

Handle contract refs in publish form -- Resolve / deploy all linked contracts in publish metadata, and pass the addresses as constructor args for corresponding params.

It recursively deploys all referenced contracts through the ref chain, before deploying the main contract.


PR-Codex overview

This PR focuses on enhancing the contract deployment process by introducing dynamic parameters, improving form handling for contract parameters, and refining the user interface for deploying contracts with references to other contracts.

Detailed summary

  • Changed error handling in deploy-with-abi.ts to return the address if already deployed.
  • Updated trusted-forwarders-fieldset.tsx to cast trusted forwarders to string.
  • Introduced DynamicParams type in deploy-metadata.ts for dynamic values.
  • Added dynamicValue support in multiple components for contract parameters.
  • Implemented RefInputFieldset and DecodedInputArrayFieldset to manage dynamic inputs.
  • Enhanced ContractPublishForm to support new implementation parameters.
  • Updated CustomContractForm to handle dynamic values and references.
  • Improved UI elements for adding and managing contract references.
  • Refined the deployment process to handle dynamic parameters effectively.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

changeset-bot bot commented Nov 8, 2024

⚠️ No Changeset found

Latest commit: 037c98d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Nov 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 2:36pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 2:36pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 2:36pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 2:36pm

Copy link

graphite-app bot commented Nov 8, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added Dashboard Involves changes to the Dashboard. packages labels Nov 8, 2024
Copy link
Contributor

github-actions bot commented Nov 8, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 44.8 KB (0%) 896 ms (0%) 922 ms (+47.17% 🔺) 1.9 s
thirdweb (cjs) 105.11 KB (0%) 2.2 s (0%) 1.1 s (-22.37% 🔽) 3.2 s
thirdweb (minimal + tree-shaking) 5.72 KB (0%) 115 ms (0%) 62 ms (+113.53% 🔺) 176 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 37 ms (+38.06% 🔺) 47 ms
thirdweb/react (minimal + tree-shaking) 18.79 KB (0%) 376 ms (0%) 119 ms (+4.5% 🔺) 494 ms

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 16.44737% with 127 lines in your changes missing coverage. Please review.

Project coverage is 45.42%. Comparing base (5585def) to head (037c98d).

Files with missing lines Patch % Lines
...rdweb/src/extensions/prebuilts/deploy-published.ts 16.55% 126 Missing ⚠️
...hirdweb/src/contract/deployment/deploy-with-abi.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5360      +/-   ##
==========================================
- Coverage   45.50%   45.42%   -0.09%     
==========================================
  Files        1071     1070       -1     
  Lines       55718    55835     +117     
  Branches     4032     4043      +11     
==========================================
+ Hits        25357    25364       +7     
- Misses      29674    29784     +110     
  Partials      687      687              
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from de96719
packages 40.52% <16.44%> (-0.10%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...ages/thirdweb/src/utils/any-evm/deploy-metadata.ts 79.71% <ø> (ø)
...hirdweb/src/contract/deployment/deploy-with-abi.ts 38.46% <0.00%> (ø)
...rdweb/src/extensions/prebuilts/deploy-published.ts 53.88% <16.55%> (-28.57%) ⬇️

... and 3 files with indirect coverage changes

@vercel vercel bot temporarily deployed to Preview – wallet-ui November 9, 2024 15:56 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground November 9, 2024 15:56 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 November 9, 2024 15:56 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground November 14, 2024 21:40 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 November 14, 2024 21:40 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui November 14, 2024 21:40 Inactive
@kumaryash90
Copy link
Member Author

@kumaryash90 could you link a linear ticket in the description? Need context to review this

https://linear.app/thirdweb/project/[contract-tooling]-deployment-publish-flow-revamp-0194e04e2a84/overview

@@ -128,6 +129,187 @@ export type DeployContractfromDeployMetadataOptions = {
salt?: string;
};

interface DynamicParams {
Copy link
Member

Choose a reason for hiding this comment

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

use type everywhere

paramValue: string | ImplementationConstructorParam;
};

async function processRefDeployments(
Copy link
Member

Choose a reason for hiding this comment

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

add unit test

Copy link
Member

Choose a reason for hiding this comment

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

move to its own file too pls

chain,
account,
contractId: contracts[0]?.contractId as string,
publisher: contracts[0]?.publisherAddress,
Copy link
Member

Choose a reason for hiding this comment

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

throw clear err if none of those are defined


if (dynamicValue.type === "bytes[]") {
const bytesArray = [];
const decodedBytesArray = dynamicValue.decodedBytes;
Copy link
Member

Choose a reason for hiding this comment

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

paramsToEncode ?

values.push(v.defaultValue);
}

if (v.dynamicValue) {
Copy link
Member

Choose a reason for hiding this comment

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

else ?

bytesArray.push(
encodeAbiParameters(
types.map((t) => {
return { name: "", type: t };
Copy link
Member

Choose a reason for hiding this comment

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

remove name

} catch (e: any) {
const err = "error" in e ? e.error?.message : e?.message;

if (err.toString().includes("Contract already deployed")) {
Copy link
Member

Choose a reason for hiding this comment

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

remove

}
}

return JSON.stringify(bytesArray);
Copy link
Member

Choose a reason for hiding this comment

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

dont think you need this?

@@ -159,6 +159,27 @@ type ParsedCompilerMetadata = {
zk_version?: string;
};

type DynamicParams = {
Copy link
Member

Choose a reason for hiding this comment

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

export this and re-use?

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

Successfully merging this pull request may close these issues.

3 participants