Gasless publish flow (#216)
* gasless publish flow * switch to publishing one at a time for now to support gasless
This commit is contained in:
@@ -91,7 +91,12 @@ export function usePublishMutation() {
|
||||
sdk && "getPublisher" in sdk,
|
||||
"sdk is not ready or does not support publishing",
|
||||
);
|
||||
return await (await sdk.getPublisher()).publishBatch(uris);
|
||||
// FIXME - can't call batch here because of a bug with multicall + gasless setup. Looping through the uris and calling publish one by one for now.
|
||||
const receipts = [];
|
||||
for (const uri of uris) {
|
||||
receipts.push(await sdk.getPublisher().publish(uri));
|
||||
}
|
||||
return receipts;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ThirdwebSDKProvider, useSigner } from "@thirdweb-dev/react";
|
||||
import { SUPPORTED_CHAIN_ID } from "@thirdweb-dev/sdk";
|
||||
import { ChainId, SDKOptions, SUPPORTED_CHAIN_ID } from "@thirdweb-dev/sdk";
|
||||
import {
|
||||
StorageSingleton,
|
||||
alchemyUrlMap,
|
||||
@@ -9,7 +9,8 @@ import { useProvider } from "wagmi";
|
||||
|
||||
export const CustomSDKContext: ComponentWithChildren<{
|
||||
desiredChainId?: SUPPORTED_CHAIN_ID | -1;
|
||||
}> = ({ desiredChainId, children }) => {
|
||||
options?: SDKOptions;
|
||||
}> = ({ desiredChainId, options, children }) => {
|
||||
const signer = useSigner();
|
||||
const provider = useProvider();
|
||||
|
||||
@@ -29,6 +30,7 @@ export const CustomSDKContext: ComponentWithChildren<{
|
||||
rpcUrl: alchemyUrlMap[desiredChainId],
|
||||
}
|
||||
: undefined,
|
||||
...options,
|
||||
}}
|
||||
storageInterface={StorageSingleton}
|
||||
>
|
||||
@@ -36,3 +38,20 @@ export const CustomSDKContext: ComponentWithChildren<{
|
||||
</ThirdwebSDKProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export const PublisherSDKContext: ComponentWithChildren = ({ children }) => (
|
||||
<CustomSDKContext
|
||||
desiredChainId={ChainId.Polygon}
|
||||
options={{
|
||||
gasless: {
|
||||
openzeppelin: {
|
||||
relayerUrl:
|
||||
"https://api.defender.openzeppelin.com/autotasks/a94b58a0-dc78-4df7-bd4e-e123d165d5ad/runs/webhook/7d6a1834-dd33-4b7b-8af4-b6b4719a0b97/J1a6Dwmk2cMZGs1b4273tj",
|
||||
relayerForwarderAddress: "0xc82BbE41f2cF04e3a8efA18F7032BDD7f6d98a81",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</CustomSDKContext>
|
||||
);
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
"@tanstack/react-location": "^3.7.4",
|
||||
"@thirdweb-dev/chain-icons": "^1.0.4",
|
||||
"@thirdweb-dev/react": "^2.4.6",
|
||||
"@thirdweb-dev/sdk": "^2.3.20",
|
||||
"@thirdweb-dev/sdk": "^2.3.21-1",
|
||||
"bn.js": "^5.2.0",
|
||||
"color": "^4.0.1",
|
||||
"date-fns": "^2.28.0",
|
||||
|
||||
@@ -8,12 +8,11 @@ import {
|
||||
Spinner,
|
||||
} from "@chakra-ui/react";
|
||||
import { useAddress } from "@thirdweb-dev/react";
|
||||
import { ChainId } from "@thirdweb-dev/sdk";
|
||||
import { AppLayout } from "components/app-layouts/app";
|
||||
import { DeployableContractTable } from "components/contract-components/contract-table";
|
||||
import { usePublishedContractsQuery } from "components/contract-components/hooks";
|
||||
import { BuiltinContractMap } from "constants/mappings";
|
||||
import { CustomSDKContext } from "contexts/custom-sdk-context";
|
||||
import { PublisherSDKContext } from "contexts/custom-sdk-context";
|
||||
import { useTrack } from "hooks/analytics/useTrack";
|
||||
import { ReactElement } from "react";
|
||||
import { IoRefreshSharp } from "react-icons/io5";
|
||||
@@ -118,9 +117,9 @@ const ContractsHomepageWrapped: React.FC = () => {
|
||||
|
||||
export default function ContractsHomepage() {
|
||||
return (
|
||||
<CustomSDKContext desiredChainId={ChainId.Mumbai}>
|
||||
<PublisherSDKContext>
|
||||
<ContractsHomepageWrapped />
|
||||
</CustomSDKContext>
|
||||
</PublisherSDKContext>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ import {
|
||||
Spinner,
|
||||
VStack,
|
||||
} from "@chakra-ui/react";
|
||||
import { ChainId, useAddress } from "@thirdweb-dev/react";
|
||||
import { useAddress } from "@thirdweb-dev/react";
|
||||
import { AppLayout } from "components/app-layouts/app";
|
||||
import { DeployableContractTable } from "components/contract-components/contract-table";
|
||||
import { usePublishedContractsQuery } from "components/contract-components/hooks";
|
||||
import { CustomSDKContext } from "contexts/custom-sdk-context";
|
||||
import { PublisherSDKContext } from "contexts/custom-sdk-context";
|
||||
import { useRouter } from "next/router";
|
||||
import React, { ReactElement } from "react";
|
||||
import { FiChevronLeft } from "react-icons/fi";
|
||||
@@ -134,9 +134,9 @@ function DeployCustomContract() {
|
||||
|
||||
export default function DeployCustomContractWrapped() {
|
||||
return (
|
||||
<CustomSDKContext desiredChainId={ChainId.Mumbai}>
|
||||
<PublisherSDKContext>
|
||||
<DeployCustomContract />
|
||||
</CustomSDKContext>
|
||||
</PublisherSDKContext>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Box, Flex, Link } from "@chakra-ui/react";
|
||||
import { ChainId } from "@thirdweb-dev/sdk";
|
||||
import { AppLayout } from "components/app-layouts/app";
|
||||
import { TransactionButton } from "components/buttons/TransactionButton";
|
||||
import { DeployableContractTable } from "components/contract-components/contract-table";
|
||||
import { usePublishMutation } from "components/contract-components/hooks";
|
||||
import { ContractId } from "components/contract-components/types";
|
||||
import { UrlMap } from "constants/mappings";
|
||||
import { CustomSDKContext } from "contexts/custom-sdk-context";
|
||||
import { PublisherSDKContext } from "contexts/custom-sdk-context";
|
||||
import { useTrack } from "hooks/analytics/useTrack";
|
||||
import { useTxNotifications } from "hooks/useTxNotifications";
|
||||
import { useRouter } from "next/router";
|
||||
@@ -103,7 +102,7 @@ const ContractsPublishPageWrapped: React.FC = () => {
|
||||
<TransactionButton
|
||||
colorScheme="primary"
|
||||
isDisabled={!publishContractNo}
|
||||
transactionCount={1}
|
||||
transactionCount={publishContractNo}
|
||||
isLoading={publishMutation.isLoading}
|
||||
onClick={() => {
|
||||
trackEvent({
|
||||
@@ -146,9 +145,9 @@ const ContractsPublishPageWrapped: React.FC = () => {
|
||||
|
||||
export default function ContractsPublishPage() {
|
||||
return (
|
||||
<CustomSDKContext desiredChainId={ChainId.Mumbai}>
|
||||
<PublisherSDKContext>
|
||||
<ContractsPublishPageWrapped />
|
||||
</CustomSDKContext>
|
||||
</PublisherSDKContext>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1853,10 +1853,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@thirdweb-dev/chain-icons/-/chain-icons-1.0.4.tgz#5b8b88995f71628885d8e72b679fe0631d281036"
|
||||
integrity sha512-veUEsYonSUH3d+OF71eAUnwngDRzaveKbSZqcHNR6MpZExAMYMMnnVW8gsR+S6GLyLGQHahoUnsxqWZZN7Bx2w==
|
||||
|
||||
"@thirdweb-dev/contracts@2.3.15-0":
|
||||
version "2.3.15-0"
|
||||
resolved "https://registry.yarnpkg.com/@thirdweb-dev/contracts/-/contracts-2.3.15-0.tgz#9ea4aa8500b213356acc1772c18222c8085087c0"
|
||||
integrity sha512-hm6qK5GSp776ctXV3NeA6jvHHfkolJjTLXQ/ed9gZVBLVD5Bl1ofLRZ30wG3lf8eMMxFoJCEqOsoQlB95M+qOw==
|
||||
"@thirdweb-dev/contracts@2.4.1":
|
||||
version "2.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@thirdweb-dev/contracts/-/contracts-2.4.1.tgz#50a5d5f19fa79aa7607fa64fe6bb28e474403866"
|
||||
integrity sha512-It1lEQ55Wpad+XlzymlyFeG/j0mBy7qMbACf0615PVoqV1bvQbV1PCaXr4v0toNsDZRemwInINIGUGc27dDT5w==
|
||||
|
||||
"@thirdweb-dev/react@^2.4.6":
|
||||
version "2.4.6"
|
||||
@@ -1873,12 +1873,12 @@
|
||||
tiny-invariant "^1.2.0"
|
||||
wagmi "^0.2.28"
|
||||
|
||||
"@thirdweb-dev/sdk@^2.3.20":
|
||||
version "2.3.20"
|
||||
resolved "https://registry.yarnpkg.com/@thirdweb-dev/sdk/-/sdk-2.3.20.tgz#b096fdedaf156e1ffbeb0ee6bb03a6ab4e899036"
|
||||
integrity sha512-h0qA7jGaDWMRPCcsBRrEPVRXkgo/2KSYevtW4ql5od8aNvPI+tY+h7wa0CL9bPz5MDbXQGqPe08jPkV7kUSNrw==
|
||||
"@thirdweb-dev/sdk@^2.3.21-1":
|
||||
version "2.3.21-1"
|
||||
resolved "https://registry.yarnpkg.com/@thirdweb-dev/sdk/-/sdk-2.3.21-1.tgz#7860b808c4dc61d935ec95be448a289f64c746fe"
|
||||
integrity sha512-nqyuGKtzTIWexuUybQiVYqjOCrdqndOLFHBekzNx0syxN2ujGm5jc3mhzu2VNI7NSZSoupm/pEYN9BX0EU/8fQ==
|
||||
dependencies:
|
||||
"@thirdweb-dev/contracts" "2.3.15-0"
|
||||
"@thirdweb-dev/contracts" "2.4.1"
|
||||
"@web-std/file" "^3.0.0"
|
||||
cbor "^8.1.0"
|
||||
cross-fetch "^3.1.5"
|
||||
|
||||
Reference in New Issue
Block a user