thirdweb 5.60.1 → 5.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/contract/deployment/utils/create-2-factory.js +53 -46
- package/dist/cjs/contract/deployment/utils/create-2-factory.js.map +1 -1
- package/dist/cjs/event/actions/get-events.js +4 -4
- package/dist/cjs/event/actions/get-events.js.map +1 -1
- package/dist/cjs/exports/extensions/unstoppable-domains.js +10 -0
- package/dist/cjs/exports/extensions/unstoppable-domains.js.map +1 -0
- package/dist/cjs/exports/react.js +4 -2
- package/dist/cjs/exports/react.js.map +1 -1
- package/dist/cjs/exports/react.native.js +3 -1
- package/dist/cjs/exports/react.native.js.map +1 -1
- package/dist/cjs/exports/wallets.js.map +1 -1
- package/dist/cjs/exports/wallets.native.js.map +1 -1
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.js +122 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.js +115 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.js +115 -0
- package/dist/cjs/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/consts.js +5 -0
- package/dist/cjs/extensions/unstoppable-domains/consts.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/read/resolveAddress.js +77 -0
- package/dist/cjs/extensions/unstoppable-domains/read/resolveAddress.js.map +1 -0
- package/dist/cjs/extensions/unstoppable-domains/read/resolveName.js +60 -0
- package/dist/cjs/extensions/unstoppable-domains/read/resolveName.js.map +1 -0
- package/dist/cjs/react/native/hooks/wallets/useLinkProfile.js +92 -0
- package/dist/cjs/react/native/hooks/wallets/useLinkProfile.js.map +1 -0
- package/dist/cjs/react/native/hooks/wallets/useProfiles.js +3 -4
- package/dist/cjs/react/native/hooks/wallets/useProfiles.js.map +1 -1
- package/dist/cjs/react/web/hooks/wallets/useLinkProfile.js +91 -0
- package/dist/cjs/react/web/hooks/wallets/useLinkProfile.js.map +1 -0
- package/dist/cjs/react/web/hooks/wallets/useProfiles.js +3 -4
- package/dist/cjs/react/web/hooks/wallets/useProfiles.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js +2 -1
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/in-app/core/users/getUser.js +11 -8
- package/dist/cjs/wallets/in-app/core/users/getUser.js.map +1 -1
- package/dist/cjs/wallets/in-app/native/native-connector.js +1 -0
- package/dist/cjs/wallets/in-app/native/native-connector.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/auth/index.js +23 -16
- package/dist/cjs/wallets/in-app/web/lib/auth/index.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js +1 -0
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/esm/contract/deployment/utils/create-2-factory.js +53 -46
- package/dist/esm/contract/deployment/utils/create-2-factory.js.map +1 -1
- package/dist/esm/event/actions/get-events.js +4 -4
- package/dist/esm/event/actions/get-events.js.map +1 -1
- package/dist/esm/exports/extensions/unstoppable-domains.js +4 -0
- package/dist/esm/exports/extensions/unstoppable-domains.js.map +1 -0
- package/dist/esm/exports/react.js +1 -0
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/exports/react.native.js +1 -0
- package/dist/esm/exports/react.native.js.map +1 -1
- package/dist/esm/exports/wallets.js.map +1 -1
- package/dist/esm/exports/wallets.native.js.map +1 -1
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.js +114 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.js +107 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.js +107 -0
- package/dist/esm/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/consts.js +2 -0
- package/dist/esm/extensions/unstoppable-domains/consts.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/read/resolveAddress.js +74 -0
- package/dist/esm/extensions/unstoppable-domains/read/resolveAddress.js.map +1 -0
- package/dist/esm/extensions/unstoppable-domains/read/resolveName.js +57 -0
- package/dist/esm/extensions/unstoppable-domains/read/resolveName.js.map +1 -0
- package/dist/esm/react/native/hooks/wallets/useLinkProfile.js +89 -0
- package/dist/esm/react/native/hooks/wallets/useLinkProfile.js.map +1 -0
- package/dist/esm/react/native/hooks/wallets/useProfiles.js +3 -4
- package/dist/esm/react/native/hooks/wallets/useProfiles.js.map +1 -1
- package/dist/esm/react/web/hooks/wallets/useLinkProfile.js +88 -0
- package/dist/esm/react/web/hooks/wallets/useLinkProfile.js.map +1 -0
- package/dist/esm/react/web/hooks/wallets/useProfiles.js +3 -4
- package/dist/esm/react/web/hooks/wallets/useProfiles.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js +2 -1
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/in-app/core/users/getUser.js +11 -8
- package/dist/esm/wallets/in-app/core/users/getUser.js.map +1 -1
- package/dist/esm/wallets/in-app/native/native-connector.js +1 -0
- package/dist/esm/wallets/in-app/native/native-connector.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/auth/index.js +23 -16
- package/dist/esm/wallets/in-app/web/lib/auth/index.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/web-connector.js +1 -0
- package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/types/contract/deployment/utils/create-2-factory.d.ts.map +1 -1
- package/dist/types/exports/extensions/unstoppable-domains.d.ts +4 -0
- package/dist/types/exports/extensions/unstoppable-domains.d.ts.map +1 -0
- package/dist/types/exports/react.d.ts +1 -0
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/exports/react.native.d.ts +1 -0
- package/dist/types/exports/react.native.d.ts.map +1 -1
- package/dist/types/exports/wallets.d.ts +1 -0
- package/dist/types/exports/wallets.d.ts.map +1 -1
- package/dist/types/exports/wallets.native.d.ts +1 -0
- package/dist/types/exports/wallets.native.d.ts.map +1 -1
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.d.ts +90 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.d.ts +83 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.d.ts +83 -0
- package/dist/types/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/consts.d.ts +2 -0
- package/dist/types/extensions/unstoppable-domains/consts.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/read/resolveAddress.d.ts +45 -0
- package/dist/types/extensions/unstoppable-domains/read/resolveAddress.d.ts.map +1 -0
- package/dist/types/extensions/unstoppable-domains/read/resolveName.d.ts +43 -0
- package/dist/types/extensions/unstoppable-domains/read/resolveName.d.ts.map +1 -0
- package/dist/types/react/native/hooks/wallets/useLinkProfile.d.ts +74 -0
- package/dist/types/react/native/hooks/wallets/useLinkProfile.d.ts.map +1 -0
- package/dist/types/react/native/hooks/wallets/useProfiles.d.ts +3 -4
- package/dist/types/react/native/hooks/wallets/useProfiles.d.ts.map +1 -1
- package/dist/types/react/web/hooks/wallets/useLinkProfile.d.ts +73 -0
- package/dist/types/react/web/hooks/wallets/useLinkProfile.d.ts.map +1 -0
- package/dist/types/react/web/hooks/wallets/useProfiles.d.ts +3 -4
- package/dist/types/react/web/hooks/wallets/useProfiles.d.ts.map +1 -1
- package/dist/types/utils/any-evm/zksync/isZkSyncChain.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/in-app/core/authentication/types.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/users/getUser.d.ts +8 -6
- package/dist/types/wallets/in-app/core/users/getUser.d.ts.map +1 -1
- package/dist/types/wallets/in-app/native/native-connector.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/auth/index.d.ts +23 -16
- package/dist/types/wallets/in-app/web/lib/auth/index.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/contract/deployment/utils/create-2-factory.ts +70 -57
- package/src/event/actions/get-events.ts +4 -4
- package/src/exports/extensions/unstoppable-domains.ts +9 -0
- package/src/exports/react.native.ts +1 -0
- package/src/exports/react.ts +1 -0
- package/src/exports/wallets.native.ts +1 -0
- package/src/exports/wallets.ts +1 -0
- package/src/extensions/thirdweb/write/publish.test.ts +20 -12
- package/src/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/getMany.ts +130 -0
- package/src/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/namehash.ts +124 -0
- package/src/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.ts +126 -0
- package/src/extensions/unstoppable-domains/consts.ts +1 -0
- package/src/extensions/unstoppable-domains/read/resolveAddress.test.ts +18 -0
- package/src/extensions/unstoppable-domains/read/resolveAddress.ts +96 -0
- package/src/extensions/unstoppable-domains/read/resolveName.test.ts +16 -0
- package/src/extensions/unstoppable-domains/read/resolveName.ts +77 -0
- package/src/react/native/hooks/wallets/useLinkProfile.ts +92 -0
- package/src/react/native/hooks/wallets/useProfiles.ts +3 -4
- package/src/react/web/hooks/wallets/useLinkProfile.ts +91 -0
- package/src/react/web/hooks/wallets/useProfiles.ts +3 -4
- package/src/utils/any-evm/zksync/isZkSyncChain.ts +2 -1
- package/src/version.ts +1 -1
- package/src/wallets/in-app/core/authentication/types.ts +1 -0
- package/src/wallets/in-app/core/users/getUser.ts +14 -7
- package/src/wallets/in-app/native/native-connector.ts +1 -0
- package/src/wallets/in-app/web/lib/auth/index.ts +23 -16
- package/src/wallets/in-app/web/lib/web-connector.ts +1 -0
@@ -9,6 +9,7 @@ import { prepareTransaction } from "../../../transaction/prepare-transaction.js"
|
|
9
9
|
import { isEIP155Enforced } from "../../../utils/any-evm/is-eip155-enforced.js";
|
10
10
|
import { getKeylessTransaction } from "../../../utils/any-evm/keyless-transaction.js";
|
11
11
|
import { isContractDeployed } from "../../../utils/bytecode/is-contract-deployed.js";
|
12
|
+
import { withCache } from "../../../utils/promise/withCache.js";
|
12
13
|
import type {
|
13
14
|
ClientAndChain,
|
14
15
|
ClientAndChainAndAccount,
|
@@ -42,73 +43,85 @@ export async function computeCreate2FactoryAddress(
|
|
42
43
|
): Promise<string> {
|
43
44
|
const chainId = options.chain.id;
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
return withCache(
|
47
|
+
async () => {
|
48
|
+
// special handling for chains with hardcoded gasPrice and gasLimit
|
49
|
+
if (CUSTOM_GAS_FOR_CHAIN[chainId]) {
|
50
|
+
const enforceEip155 = await isEIP155Enforced(options);
|
51
|
+
const eipChain = enforceEip155 ? chainId : 0;
|
52
|
+
const gasPrice = CUSTOM_GAS_FOR_CHAIN[chainId.toString()]?.gasPrice;
|
53
|
+
const gasLimit = CUSTOM_GAS_FOR_CHAIN[chainId.toString()]?.gasLimit;
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
const deploymentInfo = await _getCreate2FactoryDeploymentInfo(
|
56
|
+
eipChain,
|
57
|
+
{
|
58
|
+
gasPrice,
|
59
|
+
gasLimit,
|
60
|
+
},
|
61
|
+
);
|
56
62
|
|
57
|
-
|
58
|
-
|
63
|
+
return deploymentInfo.predictedAddress;
|
64
|
+
}
|
59
65
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
+
// default flow
|
67
|
+
const allBinsInfo = await Promise.all([
|
68
|
+
// to generate EIP-155 transaction
|
69
|
+
...CUSTOM_GAS_BINS.map((b) => {
|
70
|
+
return _getCreate2FactoryDeploymentInfo(chainId, { gasPrice: b });
|
71
|
+
}),
|
66
72
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
73
|
+
// to generate pre EIP-155 transaction, hence chainId 0
|
74
|
+
...CUSTOM_GAS_BINS.map((b) => {
|
75
|
+
return _getCreate2FactoryDeploymentInfo(0, { gasPrice: b });
|
76
|
+
}),
|
77
|
+
]);
|
72
78
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
const allFactories = await Promise.all(
|
80
|
+
allBinsInfo.map((b) => {
|
81
|
+
const tempFactory = getContract({
|
82
|
+
...options,
|
83
|
+
address: b.predictedAddress,
|
84
|
+
});
|
85
|
+
return isContractDeployed(tempFactory);
|
86
|
+
}),
|
87
|
+
);
|
82
88
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
+
const indexOfCommonFactory = allBinsInfo.findIndex(
|
90
|
+
(b) => b.predictedAddress === COMMON_FACTORY_ADDRESS,
|
91
|
+
);
|
92
|
+
if (indexOfCommonFactory && allFactories[indexOfCommonFactory]) {
|
93
|
+
return COMMON_FACTORY_ADDRESS;
|
94
|
+
}
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
const indexOfExistingDeployment = allFactories.findIndex((b) => b);
|
97
|
+
if (
|
98
|
+
indexOfExistingDeployment &&
|
99
|
+
allBinsInfo &&
|
100
|
+
allBinsInfo[indexOfExistingDeployment]?.predictedAddress
|
101
|
+
) {
|
102
|
+
// TODO: cleanup
|
103
|
+
return allBinsInfo[indexOfExistingDeployment]
|
104
|
+
?.predictedAddress as string;
|
105
|
+
}
|
99
106
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
107
|
+
const [enforceEip155, gasPriceFetched] = await Promise.all([
|
108
|
+
isEIP155Enforced(options),
|
109
|
+
getGasPrice(options),
|
110
|
+
]);
|
111
|
+
const eipChain = enforceEip155 ? chainId : 0;
|
112
|
+
const bin = _getNearestGasPriceBin(gasPriceFetched);
|
106
113
|
|
107
|
-
|
108
|
-
|
109
|
-
|
114
|
+
const deploymentInfo = await _getCreate2FactoryDeploymentInfo(eipChain, {
|
115
|
+
gasPrice: bin,
|
116
|
+
});
|
110
117
|
|
111
|
-
|
118
|
+
return deploymentInfo.predictedAddress;
|
119
|
+
},
|
120
|
+
{
|
121
|
+
cacheKey: `create2factory:${chainId}`,
|
122
|
+
cacheTime: 24 * 60 * 60 * 1000, // 1 day
|
123
|
+
},
|
124
|
+
);
|
112
125
|
}
|
113
126
|
|
114
127
|
/**
|
@@ -124,8 +124,8 @@ export async function getContractEvents<
|
|
124
124
|
|
125
125
|
// Make sure the inputs were properly defined
|
126
126
|
if (
|
127
|
-
fromBlock &&
|
128
|
-
toBlock &&
|
127
|
+
fromBlock !== undefined &&
|
128
|
+
toBlock !== undefined &&
|
129
129
|
BigInt(toBlock) - BigInt(fromBlock) !== BigInt(blockRange)
|
130
130
|
) {
|
131
131
|
throw new Error(
|
@@ -133,9 +133,9 @@ export async function getContractEvents<
|
|
133
133
|
);
|
134
134
|
}
|
135
135
|
|
136
|
-
if (fromBlock) {
|
136
|
+
if (fromBlock !== undefined) {
|
137
137
|
restParams.toBlock = BigInt(fromBlock) + BigInt(blockRange) - 1n; // Subtract one because toBlock is inclusive
|
138
|
-
} else if (toBlock) {
|
138
|
+
} else if (toBlock !== undefined) {
|
139
139
|
restParams.fromBlock = BigInt(toBlock) - BigInt(blockRange) + 1n; // Add one because fromBlock is inclusive
|
140
140
|
} else {
|
141
141
|
// If no from or to block specified, use the latest block as the to block
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export { UD_POLYGON_MAINNET } from "../../extensions/unstoppable-domains/consts.js";
|
2
|
+
export {
|
3
|
+
type ResolveUDNameOptions,
|
4
|
+
resolveName,
|
5
|
+
} from "../../extensions/unstoppable-domains/read/resolveName.js";
|
6
|
+
export {
|
7
|
+
type ResolveAddressOptions,
|
8
|
+
resolveAddress,
|
9
|
+
} from "../../extensions/unstoppable-domains/read/resolveAddress.js";
|
@@ -26,6 +26,7 @@ export { useSwitchActiveWalletChain } from "../react/core/hooks/wallets/useSwitc
|
|
26
26
|
export { useCallsStatus } from "../react/core/hooks/wallets/useCallsStatus.js";
|
27
27
|
export { useWalletBalance } from "../react/core/hooks/others/useWalletBalance.js";
|
28
28
|
export { useProfiles } from "../react/native/hooks/wallets/useProfiles.js";
|
29
|
+
export { useLinkProfile } from "../react/native/hooks/wallets/useLinkProfile.js";
|
29
30
|
|
30
31
|
// contract
|
31
32
|
export { useReadContract } from "../react/core/hooks/contract/useReadContract.js";
|
package/src/exports/react.ts
CHANGED
@@ -57,6 +57,7 @@ export { useSwitchActiveWalletChain } from "../react/core/hooks/wallets/useSwitc
|
|
57
57
|
export { useCallsStatus } from "../react/core/hooks/wallets/useCallsStatus.js";
|
58
58
|
export { useWalletBalance } from "../react/core/hooks/others/useWalletBalance.js";
|
59
59
|
export { useProfiles } from "../react/web/hooks/wallets/useProfiles.js";
|
60
|
+
export { useLinkProfile } from "../react/web/hooks/wallets/useLinkProfile.js";
|
60
61
|
|
61
62
|
// chain hooks
|
62
63
|
export { useChainMetadata } from "../react/core/hooks/others/useChainQuery.js";
|
@@ -99,6 +99,7 @@ export {
|
|
99
99
|
getProfiles,
|
100
100
|
linkProfile,
|
101
101
|
} from "../wallets/in-app/native/auth/index.js";
|
102
|
+
export type { Profile } from "../wallets/in-app/core/authentication/types.js";
|
102
103
|
export const authenticateWithRedirect = () => {
|
103
104
|
throw new Error("Not supported in native");
|
104
105
|
};
|
package/src/exports/wallets.ts
CHANGED
@@ -7,21 +7,25 @@ import { CONTRACT_PUBLISHER_ADDRESS } from "../../../contract/deployment/publish
|
|
7
7
|
import { parseEventLogs } from "../../../event/actions/parse-logs.js";
|
8
8
|
import { download } from "../../../storage/download.js";
|
9
9
|
import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and-confirm-transaction.js";
|
10
|
-
import {
|
10
|
+
import {
|
11
|
+
type FetchDeployMetadataResult,
|
12
|
+
fetchDeployMetadata,
|
13
|
+
} from "../../../utils/any-evm/deploy-metadata.js";
|
11
14
|
import { contractPublishedEvent } from "../__generated__/IContractPublisher/events/ContractPublished.js";
|
12
15
|
import { getAllPublishedContracts } from "../__generated__/IContractPublisher/read/getAllPublishedContracts.js";
|
13
16
|
import { getPublishedContractVersions } from "../__generated__/IContractPublisher/read/getPublishedContractVersions.js";
|
14
17
|
import { publishContract } from "./publish.js";
|
15
18
|
|
16
|
-
describe.runIf(process.env.TW_SECRET_KEY)("publishContract", () => {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
describe.runIf(process.env.TW_SECRET_KEY).sequential("publishContract", () => {
|
20
|
+
const publisherContract = getContract({
|
21
|
+
client: TEST_CLIENT,
|
22
|
+
chain: FORKED_POLYGON_CHAIN,
|
23
|
+
address: CONTRACT_PUBLISHER_ADDRESS,
|
24
|
+
});
|
25
|
+
let publishedData: FetchDeployMetadataResult;
|
23
26
|
|
24
|
-
|
27
|
+
it("should publish a contract successfully", async () => {
|
28
|
+
const publishedContracts = await getAllPublishedContracts({
|
25
29
|
contract: publisherContract,
|
26
30
|
publisher: TEST_ACCOUNT_D.address,
|
27
31
|
});
|
@@ -80,7 +84,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("publishContract", () => {
|
|
80
84
|
"version": "0.0.1",
|
81
85
|
}
|
82
86
|
`);
|
83
|
-
|
87
|
+
publishedData = await fetchDeployMetadata({
|
84
88
|
client: TEST_CLIENT,
|
85
89
|
uri: logs?.[0]?.args.publishedContract.publishMetadataUri ?? "",
|
86
90
|
});
|
@@ -91,8 +95,10 @@ describe.runIf(process.env.TW_SECRET_KEY)("publishContract", () => {
|
|
91
95
|
expect(publishedData.description).toBe("Cat Attack NFT");
|
92
96
|
expect(publishedData.publisher).toBe(TEST_ACCOUNT_D.address);
|
93
97
|
expect(publishedData.routerType).toBe("none");
|
98
|
+
}, 120000);
|
94
99
|
|
95
|
-
|
100
|
+
it("should throw if publishing the same version", async () => {
|
101
|
+
const publishedContracts = await getAllPublishedContracts({
|
96
102
|
contract: publisherContract,
|
97
103
|
publisher: TEST_ACCOUNT_D.address,
|
98
104
|
});
|
@@ -114,7 +120,9 @@ describe.runIf(process.env.TW_SECRET_KEY)("publishContract", () => {
|
|
114
120
|
}),
|
115
121
|
}),
|
116
122
|
).rejects.toThrow("Version 0.0.1 is not greater than 0.0.1");
|
123
|
+
});
|
117
124
|
|
125
|
+
it("should publish a new version", async () => {
|
118
126
|
const tx2 = publishContract({
|
119
127
|
contract: publisherContract,
|
120
128
|
account: TEST_ACCOUNT_D,
|
@@ -143,7 +151,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("publishContract", () => {
|
|
143
151
|
});
|
144
152
|
expect(publishedData2.version).toBe("0.0.2");
|
145
153
|
|
146
|
-
publishedContracts = await getAllPublishedContracts({
|
154
|
+
const publishedContracts = await getAllPublishedContracts({
|
147
155
|
contract: publisherContract,
|
148
156
|
publisher: TEST_ACCOUNT_D.address,
|
149
157
|
});
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import { readContract } from "../../../../../transaction/read-contract.js";
|
3
|
+
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
4
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
5
|
+
import { decodeAbiParameters } from "viem";
|
6
|
+
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
7
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Represents the parameters for the "getMany" function.
|
11
|
+
*/
|
12
|
+
export type GetManyParams = {
|
13
|
+
keys: AbiParameterToPrimitiveType<{ type: "string[]"; name: "keys" }>;
|
14
|
+
tokenId: AbiParameterToPrimitiveType<{ type: "uint256"; name: "tokenId" }>;
|
15
|
+
};
|
16
|
+
|
17
|
+
export const FN_SELECTOR = "0x1bd8cc1a" as const;
|
18
|
+
const FN_INPUTS = [
|
19
|
+
{
|
20
|
+
type: "string[]",
|
21
|
+
name: "keys",
|
22
|
+
},
|
23
|
+
{
|
24
|
+
type: "uint256",
|
25
|
+
name: "tokenId",
|
26
|
+
},
|
27
|
+
] as const;
|
28
|
+
const FN_OUTPUTS = [
|
29
|
+
{
|
30
|
+
type: "string[]",
|
31
|
+
name: "values",
|
32
|
+
},
|
33
|
+
] as const;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Checks if the `getMany` method is supported by the given contract.
|
37
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
38
|
+
* @returns A boolean indicating if the `getMany` method is supported.
|
39
|
+
* @extension UNSTOPPABLE-DOMAINS
|
40
|
+
* @example
|
41
|
+
* ```ts
|
42
|
+
* import { isGetManySupported } from "thirdweb/extensions/unstoppable-domains";
|
43
|
+
* const supported = isGetManySupported(["0x..."]);
|
44
|
+
* ```
|
45
|
+
*/
|
46
|
+
export function isGetManySupported(availableSelectors: string[]) {
|
47
|
+
return detectMethod({
|
48
|
+
availableSelectors,
|
49
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
50
|
+
});
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Encodes the parameters for the "getMany" function.
|
55
|
+
* @param options - The options for the getMany function.
|
56
|
+
* @returns The encoded ABI parameters.
|
57
|
+
* @extension UNSTOPPABLE-DOMAINS
|
58
|
+
* @example
|
59
|
+
* ```ts
|
60
|
+
* import { encodeGetManyParams } from "thirdweb/extensions/unstoppable-domains";
|
61
|
+
* const result = encodeGetManyParams({
|
62
|
+
* keys: ...,
|
63
|
+
* tokenId: ...,
|
64
|
+
* });
|
65
|
+
* ```
|
66
|
+
*/
|
67
|
+
export function encodeGetManyParams(options: GetManyParams) {
|
68
|
+
return encodeAbiParameters(FN_INPUTS, [options.keys, options.tokenId]);
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Encodes the "getMany" function into a Hex string with its parameters.
|
73
|
+
* @param options - The options for the getMany function.
|
74
|
+
* @returns The encoded hexadecimal string.
|
75
|
+
* @extension UNSTOPPABLE-DOMAINS
|
76
|
+
* @example
|
77
|
+
* ```ts
|
78
|
+
* import { encodeGetMany } from "thirdweb/extensions/unstoppable-domains";
|
79
|
+
* const result = encodeGetMany({
|
80
|
+
* keys: ...,
|
81
|
+
* tokenId: ...,
|
82
|
+
* });
|
83
|
+
* ```
|
84
|
+
*/
|
85
|
+
export function encodeGetMany(options: GetManyParams) {
|
86
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
87
|
+
// we can do this because we know the specific formats of the values
|
88
|
+
return (FN_SELECTOR +
|
89
|
+
encodeGetManyParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
|
90
|
+
}
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Decodes the result of the getMany function call.
|
94
|
+
* @param result - The hexadecimal result to decode.
|
95
|
+
* @returns The decoded result as per the FN_OUTPUTS definition.
|
96
|
+
* @extension UNSTOPPABLE-DOMAINS
|
97
|
+
* @example
|
98
|
+
* ```ts
|
99
|
+
* import { decodeGetManyResult } from "thirdweb/extensions/unstoppable-domains";
|
100
|
+
* const result = decodeGetManyResultResult("...");
|
101
|
+
* ```
|
102
|
+
*/
|
103
|
+
export function decodeGetManyResult(result: Hex) {
|
104
|
+
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Calls the "getMany" function on the contract.
|
109
|
+
* @param options - The options for the getMany function.
|
110
|
+
* @returns The parsed result of the function call.
|
111
|
+
* @extension UNSTOPPABLE-DOMAINS
|
112
|
+
* @example
|
113
|
+
* ```ts
|
114
|
+
* import { getMany } from "thirdweb/extensions/unstoppable-domains";
|
115
|
+
*
|
116
|
+
* const result = await getMany({
|
117
|
+
* contract,
|
118
|
+
* keys: ...,
|
119
|
+
* tokenId: ...,
|
120
|
+
* });
|
121
|
+
*
|
122
|
+
* ```
|
123
|
+
*/
|
124
|
+
export async function getMany(options: BaseTransactionOptions<GetManyParams>) {
|
125
|
+
return readContract({
|
126
|
+
contract: options.contract,
|
127
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
128
|
+
params: [options.keys, options.tokenId],
|
129
|
+
});
|
130
|
+
}
|
@@ -0,0 +1,124 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import { readContract } from "../../../../../transaction/read-contract.js";
|
3
|
+
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
4
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
5
|
+
import { decodeAbiParameters } from "viem";
|
6
|
+
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
7
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Represents the parameters for the "namehash" function.
|
11
|
+
*/
|
12
|
+
export type NamehashParams = {
|
13
|
+
labels: AbiParameterToPrimitiveType<{ type: "string[]"; name: "labels" }>;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const FN_SELECTOR = "0x276fabb1" as const;
|
17
|
+
const FN_INPUTS = [
|
18
|
+
{
|
19
|
+
type: "string[]",
|
20
|
+
name: "labels",
|
21
|
+
},
|
22
|
+
] as const;
|
23
|
+
const FN_OUTPUTS = [
|
24
|
+
{
|
25
|
+
type: "uint256",
|
26
|
+
name: "hash",
|
27
|
+
},
|
28
|
+
] as const;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Checks if the `namehash` method is supported by the given contract.
|
32
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
33
|
+
* @returns A boolean indicating if the `namehash` method is supported.
|
34
|
+
* @extension UNSTOPPABLE-DOMAINS
|
35
|
+
* @example
|
36
|
+
* ```ts
|
37
|
+
* import { isNamehashSupported } from "thirdweb/extensions/unstoppable-domains";
|
38
|
+
* const supported = isNamehashSupported(["0x..."]);
|
39
|
+
* ```
|
40
|
+
*/
|
41
|
+
export function isNamehashSupported(availableSelectors: string[]) {
|
42
|
+
return detectMethod({
|
43
|
+
availableSelectors,
|
44
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
45
|
+
});
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Encodes the parameters for the "namehash" function.
|
50
|
+
* @param options - The options for the namehash function.
|
51
|
+
* @returns The encoded ABI parameters.
|
52
|
+
* @extension UNSTOPPABLE-DOMAINS
|
53
|
+
* @example
|
54
|
+
* ```ts
|
55
|
+
* import { encodeNamehashParams } from "thirdweb/extensions/unstoppable-domains";
|
56
|
+
* const result = encodeNamehashParams({
|
57
|
+
* labels: ...,
|
58
|
+
* });
|
59
|
+
* ```
|
60
|
+
*/
|
61
|
+
export function encodeNamehashParams(options: NamehashParams) {
|
62
|
+
return encodeAbiParameters(FN_INPUTS, [options.labels]);
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Encodes the "namehash" function into a Hex string with its parameters.
|
67
|
+
* @param options - The options for the namehash function.
|
68
|
+
* @returns The encoded hexadecimal string.
|
69
|
+
* @extension UNSTOPPABLE-DOMAINS
|
70
|
+
* @example
|
71
|
+
* ```ts
|
72
|
+
* import { encodeNamehash } from "thirdweb/extensions/unstoppable-domains";
|
73
|
+
* const result = encodeNamehash({
|
74
|
+
* labels: ...,
|
75
|
+
* });
|
76
|
+
* ```
|
77
|
+
*/
|
78
|
+
export function encodeNamehash(options: NamehashParams) {
|
79
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
80
|
+
// we can do this because we know the specific formats of the values
|
81
|
+
return (FN_SELECTOR +
|
82
|
+
encodeNamehashParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
|
83
|
+
}
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Decodes the result of the namehash function call.
|
87
|
+
* @param result - The hexadecimal result to decode.
|
88
|
+
* @returns The decoded result as per the FN_OUTPUTS definition.
|
89
|
+
* @extension UNSTOPPABLE-DOMAINS
|
90
|
+
* @example
|
91
|
+
* ```ts
|
92
|
+
* import { decodeNamehashResult } from "thirdweb/extensions/unstoppable-domains";
|
93
|
+
* const result = decodeNamehashResultResult("...");
|
94
|
+
* ```
|
95
|
+
*/
|
96
|
+
export function decodeNamehashResult(result: Hex) {
|
97
|
+
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Calls the "namehash" function on the contract.
|
102
|
+
* @param options - The options for the namehash function.
|
103
|
+
* @returns The parsed result of the function call.
|
104
|
+
* @extension UNSTOPPABLE-DOMAINS
|
105
|
+
* @example
|
106
|
+
* ```ts
|
107
|
+
* import { namehash } from "thirdweb/extensions/unstoppable-domains";
|
108
|
+
*
|
109
|
+
* const result = await namehash({
|
110
|
+
* contract,
|
111
|
+
* labels: ...,
|
112
|
+
* });
|
113
|
+
*
|
114
|
+
* ```
|
115
|
+
*/
|
116
|
+
export async function namehash(
|
117
|
+
options: BaseTransactionOptions<NamehashParams>,
|
118
|
+
) {
|
119
|
+
return readContract({
|
120
|
+
contract: options.contract,
|
121
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
122
|
+
params: [options.labels],
|
123
|
+
});
|
124
|
+
}
|
package/src/extensions/unstoppable-domains/__generated__/UnstoppableDomains/read/reverseNameOf.ts
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import { readContract } from "../../../../../transaction/read-contract.js";
|
3
|
+
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
4
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
5
|
+
import { decodeAbiParameters } from "viem";
|
6
|
+
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
7
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Represents the parameters for the "reverseNameOf" function.
|
11
|
+
*/
|
12
|
+
export type ReverseNameOfParams = {
|
13
|
+
addr: AbiParameterToPrimitiveType<{ type: "address"; name: "addr" }>;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const FN_SELECTOR = "0xbebec6b4" as const;
|
17
|
+
const FN_INPUTS = [
|
18
|
+
{
|
19
|
+
type: "address",
|
20
|
+
name: "addr",
|
21
|
+
},
|
22
|
+
] as const;
|
23
|
+
const FN_OUTPUTS = [
|
24
|
+
{
|
25
|
+
type: "string",
|
26
|
+
name: "reverseUri",
|
27
|
+
},
|
28
|
+
] as const;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Checks if the `reverseNameOf` method is supported by the given contract.
|
32
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
33
|
+
* @returns A boolean indicating if the `reverseNameOf` method is supported.
|
34
|
+
* @extension UNSTOPPABLE-DOMAINS
|
35
|
+
* @example
|
36
|
+
* ```ts
|
37
|
+
* import { isReverseNameOfSupported } from "thirdweb/extensions/unstoppable-domains";
|
38
|
+
* const supported = isReverseNameOfSupported(["0x..."]);
|
39
|
+
* ```
|
40
|
+
*/
|
41
|
+
export function isReverseNameOfSupported(availableSelectors: string[]) {
|
42
|
+
return detectMethod({
|
43
|
+
availableSelectors,
|
44
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
45
|
+
});
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Encodes the parameters for the "reverseNameOf" function.
|
50
|
+
* @param options - The options for the reverseNameOf function.
|
51
|
+
* @returns The encoded ABI parameters.
|
52
|
+
* @extension UNSTOPPABLE-DOMAINS
|
53
|
+
* @example
|
54
|
+
* ```ts
|
55
|
+
* import { encodeReverseNameOfParams } from "thirdweb/extensions/unstoppable-domains";
|
56
|
+
* const result = encodeReverseNameOfParams({
|
57
|
+
* addr: ...,
|
58
|
+
* });
|
59
|
+
* ```
|
60
|
+
*/
|
61
|
+
export function encodeReverseNameOfParams(options: ReverseNameOfParams) {
|
62
|
+
return encodeAbiParameters(FN_INPUTS, [options.addr]);
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Encodes the "reverseNameOf" function into a Hex string with its parameters.
|
67
|
+
* @param options - The options for the reverseNameOf function.
|
68
|
+
* @returns The encoded hexadecimal string.
|
69
|
+
* @extension UNSTOPPABLE-DOMAINS
|
70
|
+
* @example
|
71
|
+
* ```ts
|
72
|
+
* import { encodeReverseNameOf } from "thirdweb/extensions/unstoppable-domains";
|
73
|
+
* const result = encodeReverseNameOf({
|
74
|
+
* addr: ...,
|
75
|
+
* });
|
76
|
+
* ```
|
77
|
+
*/
|
78
|
+
export function encodeReverseNameOf(options: ReverseNameOfParams) {
|
79
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
80
|
+
// we can do this because we know the specific formats of the values
|
81
|
+
return (FN_SELECTOR +
|
82
|
+
encodeReverseNameOfParams(options).slice(
|
83
|
+
2,
|
84
|
+
)) as `${typeof FN_SELECTOR}${string}`;
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Decodes the result of the reverseNameOf function call.
|
89
|
+
* @param result - The hexadecimal result to decode.
|
90
|
+
* @returns The decoded result as per the FN_OUTPUTS definition.
|
91
|
+
* @extension UNSTOPPABLE-DOMAINS
|
92
|
+
* @example
|
93
|
+
* ```ts
|
94
|
+
* import { decodeReverseNameOfResult } from "thirdweb/extensions/unstoppable-domains";
|
95
|
+
* const result = decodeReverseNameOfResultResult("...");
|
96
|
+
* ```
|
97
|
+
*/
|
98
|
+
export function decodeReverseNameOfResult(result: Hex) {
|
99
|
+
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Calls the "reverseNameOf" function on the contract.
|
104
|
+
* @param options - The options for the reverseNameOf function.
|
105
|
+
* @returns The parsed result of the function call.
|
106
|
+
* @extension UNSTOPPABLE-DOMAINS
|
107
|
+
* @example
|
108
|
+
* ```ts
|
109
|
+
* import { reverseNameOf } from "thirdweb/extensions/unstoppable-domains";
|
110
|
+
*
|
111
|
+
* const result = await reverseNameOf({
|
112
|
+
* contract,
|
113
|
+
* addr: ...,
|
114
|
+
* });
|
115
|
+
*
|
116
|
+
* ```
|
117
|
+
*/
|
118
|
+
export async function reverseNameOf(
|
119
|
+
options: BaseTransactionOptions<ReverseNameOfParams>,
|
120
|
+
) {
|
121
|
+
return readContract({
|
122
|
+
contract: options.contract,
|
123
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
124
|
+
params: [options.addr],
|
125
|
+
});
|
126
|
+
}
|