Compare commits

..
Author SHA1 Message Date
github-actions[bot]andgithub-actions[bot] 55edaa900d Version Packages (#842)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-03-30 14:16:57 -07:00
Jonas Daniels 839fce1f6f [storage, chains, react-core] - fail fast when making HEAD request to gateway during upload & more (#843) 2023-03-30 21:10:44 +00:00
Manan Tank 1f2df55b67 react-core: add useNetwork hook (#841) 2023-03-30 20:03:12 +00:00
Adam MajmudarandJonas Daniels b7fcae6e40 [SDK] Update function signature of contract.call (#834)
Co-authored-by: Jonas Daniels <[email protected]>
2023-03-30 19:53:16 +00:00
53 changed files with 418 additions and 190 deletions
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/auth # @thirdweb-dev/auth
## 3.0.10
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@0.2.11
## 3.0.9 ## 3.0.9
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/auth", "name": "@thirdweb-dev/auth",
"version": "3.0.9", "version": "3.0.10",
"main": "dist/thirdweb-dev-auth.cjs.js", "main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js", "module": "dist/thirdweb-dev-auth.esm.js",
"browser": { "browser": {
+6
View File
@@ -1,5 +1,11 @@
# @thirdweb-dev/chains # @thirdweb-dev/chains
## 0.1.9
### Patch Changes
- [#843](https://github.com/thirdweb-dev/js/pull/843) [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d) Thanks [@jnsdls](https://github.com/jnsdls)! - update chains
## 0.1.8 ## 0.1.8
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -27,7 +27,7 @@ export default {
{ {
"name": "Shardeum Scan", "name": "Shardeum Scan",
"url": "https://explorer-liberty10.shardeum.org", "url": "https://explorer-liberty10.shardeum.org",
"standard": "none" "standard": "EIP3091"
} }
], ],
"redFlags": [ "redFlags": [
+1 -1
View File
@@ -27,7 +27,7 @@ export default {
{ {
"name": "Shardeum Scan", "name": "Shardeum Scan",
"url": "https://explorer-liberty20.shardeum.org", "url": "https://explorer-liberty20.shardeum.org",
"standard": "none" "standard": "EIP3091"
} }
], ],
"redFlags": [ "redFlags": [
+1 -1
View File
@@ -27,7 +27,7 @@ export default {
{ {
"name": "Shardeum Scan", "name": "Shardeum Scan",
"url": "https://explorer-sphinx.shardeum.org", "url": "https://explorer-sphinx.shardeum.org",
"standard": "none" "standard": "EIP3091"
} }
], ],
"redFlags": [ "redFlags": [
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/chains", "name": "@thirdweb-dev/chains",
"version": "0.1.8", "version": "0.1.9",
"main": "dist/thirdweb-dev-chains.cjs.js", "main": "dist/thirdweb-dev-chains.cjs.js",
"module": "dist/thirdweb-dev-chains.esm.js", "module": "dist/thirdweb-dev-chains.esm.js",
"browser": { "browser": {
+8
View File
@@ -1,5 +1,13 @@
# thirdweb # thirdweb
## 0.10.6
### Patch Changes
- Updated dependencies [[`b7fcae6e`](https://github.com/thirdweb-dev/js/commit/b7fcae6e40dade7a239b1a6afb1cd996c8f89910), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d)]:
- @thirdweb-dev/sdk@3.10.6
- @thirdweb-dev/storage@1.1.2
## 0.10.5 ## 0.10.5
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "thirdweb", "name": "thirdweb",
"main": "dist/cli/index.js", "main": "dist/cli/index.js",
"version": "0.10.5", "version": "0.10.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
+45
View File
@@ -1,5 +1,50 @@
# @thirdweb-dev/react-core # @thirdweb-dev/react-core
## 3.11.2
### Patch Changes
- [#834](https://github.com/thirdweb-dev/js/pull/834) [`b7fcae6e`](https://github.com/thirdweb-dev/js/commit/b7fcae6e40dade7a239b1a6afb1cd996c8f89910) Thanks [@adam-maj](https://github.com/adam-maj)! - Usage of the `useContractRead` and `useContractWrite` hooks has changed:
```js
const owner = "0x...";
const operator = "0x...";
const overrides = { gasLimit: "10000", gasPrice: "10000" };
// Old usage
const { data } = useContractRead(
contract,
"approve",
owner,
operator,
overrides,
);
const { mutateAsync } = useContractWrite(contract, "approve");
mutateAsync(owner, operator, overrides);
// New usage
const { data } = useContractRead(
contract,
"approve",
[owner, operator],
overrides,
);
const { mutateAsync } = useContractWrite(contract, "approve");
mutateAsync([owner, operator], overrides);
```
- [#841](https://github.com/thirdweb-dev/js/pull/841) [`1f2df55b`](https://github.com/thirdweb-dev/js/commit/1f2df55b673fefb0106778dca7a13406cfbcfc90) Thanks [@MananTank](https://github.com/MananTank)! - add useNetwork() hook back
- [#843](https://github.com/thirdweb-dev/js/pull/843) [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d) Thanks [@jnsdls](https://github.com/jnsdls)! - fix solana program query key resolution
- Updated dependencies [[`b7fcae6e`](https://github.com/thirdweb-dev/js/commit/b7fcae6e40dade7a239b1a6afb1cd996c8f89910), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 3.11.1 ## 3.11.1
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react-core", "name": "@thirdweb-dev/react-core",
"version": "3.11.1", "version": "3.11.2",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -0,0 +1,130 @@
import { Chain, defaultChains } from "@thirdweb-dev/chains";
import { useCallback, useState } from "react";
import { useActiveChain, useChainId } from "../../evm/hooks/wallet";
import { useSupportedChains } from "../../evm/hooks/useSupportedChains";
import { useSwitchChain, useWallet } from "./wallet-hooks";
import { assertWindowEthereum } from "@thirdweb-dev/wallets";
// this hook is only for backwards compatibility
type SwitchNetwork = (chainId: number) => Promise<
| {
data: Chain | undefined;
error: undefined;
}
| {
data: undefined;
error: Error;
}
>;
type NetworkMetadata = {
data: {
chain: Chain | { chainId: number; unsupported: true } | undefined;
chains: Chain[];
};
error: Error | undefined;
loading: boolean | undefined;
};
/**
*
* @deprecated - use `useActiveChain`, `useSwitchChain`, `useChainId` instead
*
* Hook for getting metadata about the network the current wallet is connected to and switching networks
*
* @example
* ```javascript
* import { useNetwork } from "@thirdweb-dev/react";
*
* const App = () => {
* const [, switchNetwork] = useNetwork();
* return (
* // switchNetwork is undefined if the wallet does not support programmatic network switching
* // 137 is the chainId for Polygon in this example
* <button onClick={() => switchNetwork(137)}>
* Switch Network
* </button>
* );
* };
```
*
* It's important to note that some wallet apps do not support programmatic network switching and switchNetwork will be undefined.
* For those situations, you can typically switch networks in the wallet app this hook will still work.
*
* @public
*/
export function useNetwork(): [NetworkMetadata, SwitchNetwork | undefined] {
const chain = useActiveChain();
const chainId = useChainId();
const switchChain = useSwitchChain();
const supportedChains = useSupportedChains();
const wallet = useWallet();
const isMetamaskInstalled = assertWindowEthereum(window)
? window.ethereum.isMetaMask
: false;
const isCoinbaseInstalled = assertWindowEthereum(window)
? window.ethereum.isCoinbaseWallet
: false;
// switch not supported if connected to a mobile wallet
const switchChainNotSupported =
!wallet ||
wallet.walletId === "walletConnectV1" ||
wallet.walletId === "walletConnect" ||
(wallet.walletId === "metamask" && !isMetamaskInstalled) ||
(wallet.walletId === "coinbaseWallet" && !isCoinbaseInstalled);
// error when switching network
const [error, setError] = useState<Error | undefined>(undefined);
// loading: true when switching network
const [loading, setLoading] = useState(false);
const switchNetwork: SwitchNetwork = useCallback(
async (_chainId: number) => {
// reset error and loading
setLoading(true);
setError(undefined);
try {
await switchChain(_chainId);
} catch (e: any) {
setError(e);
setLoading(false);
return {
data: undefined,
error: e,
};
}
setLoading(false);
return {
data:
supportedChains.find((c) => c.chainId === _chainId) ||
defaultChains.find((c) => c.chainId === _chainId),
error: undefined,
};
},
[switchChain, supportedChains],
);
return [
{
data: {
chain:
chainId === undefined
? undefined
: chain || { chainId, unsupported: true },
chains: wallet ? supportedChains : [],
},
error: error,
loading,
},
switchChainNotSupported ? undefined : switchNetwork,
];
}
@@ -512,20 +512,22 @@ export function useContractEvents(
export function useContractRead( export function useContractRead(
contract: RequiredParam<ValidContractInstance>, contract: RequiredParam<ValidContractInstance>,
functionName: RequiredParam<string>, functionName: RequiredParam<string>,
...args: unknown[] | [...unknown[], CallOverrides] args?: unknown[],
overrides?: CallOverrides,
) { ) {
const contractAddress = contract?.getAddress(); const contractAddress = contract?.getAddress();
return useQueryWithNetwork( return useQueryWithNetwork(
cacheKeys.contract.call(contractAddress, functionName, args), cacheKeys.contract.call(contractAddress, functionName, args, overrides),
() => { () => {
requiredParamInvariant(contract, "contract must be defined"); requiredParamInvariant(contract, "contract must be defined");
requiredParamInvariant(functionName, "function name must be provided"); requiredParamInvariant(functionName, "function name must be provided");
return ( return (
contract.call as ( contract.call as (
functionName: string, functionName: string,
...args: unknown[] | [...unknown[], CallOverrides] args?: unknown[],
overrides?: CallOverrides,
) => Promise<any> ) => Promise<any>
)(functionName, ...args); )(functionName, args, overrides);
}, },
{ {
enabled: !!contract && !!functionName, enabled: !!contract && !!functionName,
@@ -560,23 +562,17 @@ export function useContractWrite(
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return useMutation( return useMutation(
async (callParams?: unknown[] | [...unknown[], CallOverrides]) => { async (args?: unknown[], overrides?: CallOverrides) => {
requiredParamInvariant(contract, "contract must be defined"); requiredParamInvariant(contract, "contract must be defined");
requiredParamInvariant(functionName, "function name must be provided"); requiredParamInvariant(functionName, "function name must be provided");
if (!callParams?.length) {
return (
contract.call as (
functionName: string,
...args: unknown[] | [...unknown[], CallOverrides]
) => Promise<any>
)(functionName);
}
return ( return (
contract.call as ( contract.call as (
functionName: string, functionName: string,
...args: unknown[] | [...unknown[], CallOverrides] args?: unknown[],
overrides?: CallOverrides,
) => Promise<any> ) => Promise<any>
)(functionName, ...callParams); )(functionName, args, overrides);
}, },
{ {
onSettled: () => onSettled: () =>
+1
View File
@@ -17,6 +17,7 @@ export {
useSwitchChain, useSwitchChain,
useWallets, useWallets,
} from "../core/hooks/wallet-hooks"; } from "../core/hooks/wallet-hooks";
export { useNetwork } from "../core/hooks/useNetwork";
export { useThirdwebWallet } from "../core/providers/thirdweb-wallet-provider"; export { useThirdwebWallet } from "../core/providers/thirdweb-wallet-provider";
// connected wallet hooks // connected wallet hooks
@@ -7,7 +7,7 @@ import type {
QueryAllParams, QueryAllParams,
SUPPORTED_CHAIN_ID, SUPPORTED_CHAIN_ID,
} from "@thirdweb-dev/sdk"; } from "@thirdweb-dev/sdk";
import { BigNumberish, constants } from "ethers"; import { BigNumberish, CallOverrides, constants } from "ethers";
const TW_CACHE_KEY_PREFIX = "tw-cache"; const TW_CACHE_KEY_PREFIX = "tw-cache";
@@ -108,8 +108,15 @@ export const cacheKeys = {
call: ( call: (
contractAddress: RequiredParam<ContractAddress>, contractAddress: RequiredParam<ContractAddress>,
functionName: RequiredParam<string>, functionName: RequiredParam<string>,
args: unknown[], args?: unknown[],
) => createContractCacheKey(contractAddress, ["call", functionName, args]), overrides?: CallOverrides,
) =>
createContractCacheKey(contractAddress, [
"call",
functionName,
args,
overrides,
]),
app: { app: {
get: (contractAddress: RequiredParam<ContractAddress>) => get: (contractAddress: RequiredParam<ContractAddress>) =>
@@ -39,13 +39,14 @@ export function programQuery<TProgramType extends ProgramType>(
return { return {
queryKey: neverPersist( queryKey: neverPersist(
createSOLQueryKeyWithNetwork( createSOLQueryKeyWithNetwork(
["program-instance", address] as const, ["program-instance", { address, type }] as const,
network || null, network || null,
), ),
), ),
queryFn: (async () => { queryFn: (async () => {
requiredParamInvariant(sdk, "sdk is required"); requiredParamInvariant(sdk, "sdk is required");
requiredParamInvariant(address, "Address is required"); requiredParamInvariant(address, "Address is required");
// if the type is not passed in explicitly then we'll try to resolve it // if the type is not passed in explicitly then we'll try to resolve it
if (!type) { if (!type) {
// why do we call `fetchQuery` here instead of calling the sdk directly? // why do we call `fetchQuery` here instead of calling the sdk directly?
@@ -1,5 +1,7 @@
# @thirdweb-dev/react-native-compat # @thirdweb-dev/react-native-compat
## 0.2.2
## 0.2.1 ## 0.2.1
## 0.2.0 ## 0.2.0
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@thirdweb-dev/react-native-compat", "name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects", "description": "Shims for Thirdweb in React Native Projects",
"version": "0.2.1", "version": "0.2.2",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0", "license": "Apache-2.0",
+11
View File
@@ -1,5 +1,16 @@
# @thirdweb-dev/react-native # @thirdweb-dev/react-native
## 0.2.2
### Patch Changes
- Updated dependencies [[`b7fcae6e`](https://github.com/thirdweb-dev/js/commit/b7fcae6e40dade7a239b1a6afb1cd996c8f89910), [`b7fcae6e`](https://github.com/thirdweb-dev/js/commit/b7fcae6e40dade7a239b1a6afb1cd996c8f89910), [`1f2df55b`](https://github.com/thirdweb-dev/js/commit/1f2df55b673fefb0106778dca7a13406cfbcfc90), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d)]:
- @thirdweb-dev/react-core@3.11.2
- @thirdweb-dev/sdk@3.10.6
- @thirdweb-dev/chains@0.1.9
- @thirdweb-dev/storage@1.1.2
- @thirdweb-dev/wallets@0.2.11
## 0.2.1 ## 0.2.1
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react-native", "name": "@thirdweb-dev/react-native",
"version": "0.2.1", "version": "0.2.2",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
+10
View File
@@ -1,5 +1,15 @@
# @thirdweb-dev/react # @thirdweb-dev/react
## 3.11.2
### Patch Changes
- Updated dependencies [[`b7fcae6e`](https://github.com/thirdweb-dev/js/commit/b7fcae6e40dade7a239b1a6afb1cd996c8f89910), [`b7fcae6e`](https://github.com/thirdweb-dev/js/commit/b7fcae6e40dade7a239b1a6afb1cd996c8f89910), [`1f2df55b`](https://github.com/thirdweb-dev/js/commit/1f2df55b673fefb0106778dca7a13406cfbcfc90), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d)]:
- @thirdweb-dev/react-core@3.11.2
- @thirdweb-dev/sdk@3.10.6
- @thirdweb-dev/chains@0.1.9
- @thirdweb-dev/wallets@0.2.11
## 3.11.1 ## 3.11.1
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/react", "name": "@thirdweb-dev/react",
"version": "3.11.1", "version": "3.11.2",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>", "author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0", "license": "Apache-2.0",
+34
View File
@@ -1,5 +1,39 @@
# @thirdweb-dev/sdk # @thirdweb-dev/sdk
## 3.10.6
### Patch Changes
- [#834](https://github.com/thirdweb-dev/js/pull/834) [`b7fcae6e`](https://github.com/thirdweb-dev/js/commit/b7fcae6e40dade7a239b1a6afb1cd996c8f89910) Thanks [@adam-maj](https://github.com/adam-maj)! - The signature of all `contract.call` methods has been updated to the following structure:
```ts
function call(functionName: string, args: any[], overrides?: CallOverrides);
```
Meaning that the following contract call in the old format:
```ts
const owner = "0x...";
const operator = "0x...";
const overrides = { gasLimit: "10000", gasPrice: "10000" };
const res = await contract.call("approve", owner, operator, overrides);
```
Would now look like this with the changes:
```ts
const owner = "0x...";
const operator = "0x...";
const overrides = { gasLimit: "10000", gasPrice: "10000" };
const res = await contract.call("approve", [owner, operator], overrides);
```
- Updated dependencies [[`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d)]:
- @thirdweb-dev/[email protected]
- @thirdweb-dev/[email protected]
## 3.10.5 ## 3.10.5
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/sdk", "name": "@thirdweb-dev/sdk",
"version": "3.10.5", "version": "3.10.6",
"description": "The main thirdweb SDK.", "description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -414,13 +414,9 @@ export class EditionDrop extends StandardErc1155<PrebuiltEditionDrop> {
TMethod extends keyof PrebuiltEditionDrop["functions"] = keyof PrebuiltEditionDrop["functions"], TMethod extends keyof PrebuiltEditionDrop["functions"] = keyof PrebuiltEditionDrop["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<PrebuiltEditionDrop["functions"][TMethod]>,
| (any[] & Parameters<PrebuiltEditionDrop["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<PrebuiltEditionDrop["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -416,13 +416,9 @@ export class Edition extends StandardErc1155<TokenERC1155> {
TMethod extends keyof TokenERC1155["functions"] = keyof TokenERC1155["functions"], TMethod extends keyof TokenERC1155["functions"] = keyof TokenERC1155["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<TokenERC1155["functions"][TMethod]>,
| (any[] & Parameters<TokenERC1155["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<TokenERC1155["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -696,13 +696,9 @@ export class Marketplace implements UpdateableNetwork {
TMethod extends keyof MarketplaceContract["functions"] = keyof MarketplaceContract["functions"], TMethod extends keyof MarketplaceContract["functions"] = keyof MarketplaceContract["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<MarketplaceContract["functions"][TMethod]>,
| (any[] & Parameters<MarketplaceContract["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<MarketplaceContract["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -273,14 +273,10 @@ export class MarketplaceV3 implements UpdateableNetwork {
TMethod extends keyof MarketplaceV3Contract["functions"] = keyof MarketplaceV3Contract["functions"], TMethod extends keyof MarketplaceV3Contract["functions"] = keyof MarketplaceV3Contract["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<MarketplaceV3Contract["functions"][TMethod]>,
| (any[] & Parameters<MarketplaceV3Contract["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<MarketplaceV3Contract["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
/** ******************** /** ********************
@@ -432,13 +432,9 @@ export class Multiwrap extends StandardErc721<MultiwrapContract> {
TMethod extends keyof MultiwrapContract["functions"] = keyof MultiwrapContract["functions"], TMethod extends keyof MultiwrapContract["functions"] = keyof MultiwrapContract["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<MultiwrapContract["functions"][TMethod]>,
| (any[] & Parameters<MultiwrapContract["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<MultiwrapContract["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -359,13 +359,9 @@ export class NFTCollection extends StandardErc721<TokenERC721> {
TMethod extends keyof TokenERC721["functions"] = keyof TokenERC721["functions"], TMethod extends keyof TokenERC721["functions"] = keyof TokenERC721["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<TokenERC721["functions"][TMethod]>,
| (any[] & Parameters<TokenERC721["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<TokenERC721["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -613,13 +613,9 @@ export class NFTDrop extends StandardErc721<PrebuiltNFTDrop> {
TMethod extends keyof PrebuiltNFTDrop["functions"] = keyof PrebuiltNFTDrop["functions"], TMethod extends keyof PrebuiltNFTDrop["functions"] = keyof PrebuiltNFTDrop["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<PrebuiltNFTDrop["functions"][TMethod]>,
| (any[] & Parameters<PrebuiltNFTDrop["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<PrebuiltNFTDrop["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -786,14 +786,10 @@ export class Pack extends StandardErc1155<PackContract> {
TMethod extends keyof PackContract["functions"] = keyof PackContract["functions"], TMethod extends keyof PackContract["functions"] = keyof PackContract["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: any[] & Parameters<PackContract["functions"][TMethod]>,
| (any[] & Parameters<PackContract["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<PackContract["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
private detectVrf() { private detectVrf() {
@@ -509,13 +509,9 @@ export class SignatureDrop extends StandardErc721<SignatureDropContract> {
TMethod extends keyof SignatureDropContract["functions"] = keyof SignatureDropContract["functions"], TMethod extends keyof SignatureDropContract["functions"] = keyof SignatureDropContract["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<SignatureDropContract["functions"][TMethod]>,
| (any[] & Parameters<SignatureDropContract["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<SignatureDropContract["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -423,13 +423,9 @@ export class Split implements UpdateableNetwork {
TMethod extends keyof SplitContract["functions"] = keyof SplitContract["functions"], TMethod extends keyof SplitContract["functions"] = keyof SplitContract["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<SplitContract["functions"][TMethod]>,
| (any[] & Parameters<SplitContract["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<SplitContract["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -314,13 +314,9 @@ export class TokenDrop extends StandardErc20<PrebuiltTokenDrop> {
TMethod extends keyof PrebuiltTokenDrop["functions"] = keyof PrebuiltTokenDrop["functions"], TMethod extends keyof PrebuiltTokenDrop["functions"] = keyof PrebuiltTokenDrop["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<PrebuiltTokenDrop["functions"][TMethod]>,
| (any[] & Parameters<PrebuiltTokenDrop["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<PrebuiltTokenDrop["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -323,13 +323,9 @@ export class Token extends StandardErc20<TokenERC20> {
TMethod extends keyof TokenERC20["functions"] = keyof TokenERC20["functions"], TMethod extends keyof TokenERC20["functions"] = keyof TokenERC20["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<TokenERC20["functions"][TMethod]>,
| (any[] & Parameters<TokenERC20["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<TokenERC20["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -508,13 +508,9 @@ export class Vote implements UpdateableNetwork {
TMethod extends keyof VoteERC20["functions"] = keyof VoteERC20["functions"], TMethod extends keyof VoteERC20["functions"] = keyof VoteERC20["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<VoteERC20["functions"][TMethod]>,
| (any[] & Parameters<VoteERC20["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<VoteERC20["functions"][TMethod]>),
CallOverrides,
]
): Promise<any> { ): Promise<any> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
} }
@@ -381,14 +381,10 @@ export class SmartContract<
TMethod extends keyof TContract["functions"] = keyof TContract["functions"], TMethod extends keyof TContract["functions"] = keyof TContract["functions"],
>( >(
functionName: string & TMethod, functionName: string & TMethod,
...args: args?: Parameters<TContract["functions"][TMethod]>,
| (any[] & Parameters<TContract["functions"][TMethod]>) overrides?: CallOverrides,
| [
...(any[] & Parameters<TContract["functions"][TMethod]>),
CallOverrides,
]
): Promise<ReturnType<TContract["functions"][TMethod]>> { ): Promise<ReturnType<TContract["functions"][TMethod]>> {
return this.contractWrapper.call(functionName, ...args); return this.contractWrapper.call(functionName, args, overrides);
} }
/** ******************** /** ********************
@@ -274,20 +274,13 @@ export class ContractWrapper<
*/ */
public async call( public async call(
functionName: string, functionName: string,
...args: unknown[] | [...unknown[], CallOverrides] args: unknown[] = [],
overrides?: CallOverrides,
): Promise<any> { ): Promise<any> {
// parse last arg as tx options if present // parse last arg as tx options if present
let txOptions: CallOverrides | undefined; let txOptions: CallOverrides | undefined = overrides
try { ? await CallOverrideSchema.parseAsync(overrides)
if (args.length > 0 && typeof args[args.length - 1] === "object") { : undefined;
const last = args[args.length - 1];
txOptions = await CallOverrideSchema.parseAsync(last);
// if call overrides found, remove it from args array
args = args.slice(0, args.length - 1);
}
} catch (e) {
// no-op
}
const functions = extractFunctionsFromAbi(AbiSchema.parse(this.abi)).filter( const functions = extractFunctionsFromAbi(AbiSchema.parse(this.abi)).filter(
(f) => f.name === functionName, (f) => f.name === functionName,
@@ -40,6 +40,7 @@ export class Registry {
const candyMachine = await this.metaplex const candyMachine = await this.metaplex
.candyMachinesV2() .candyMachinesV2()
.findByAddress({ address: new PublicKey(address) }); .findByAddress({ address: new PublicKey(address) });
if (candyMachine) { if (candyMachine) {
return "nft-drop"; return "nft-drop";
} }
+9 -6
View File
@@ -107,7 +107,7 @@ describe("Custom Contracts", async () => {
const owner = await c.call("owner"); const owner = await c.call("owner");
expect(owner).to.eq(adminWallet.address); expect(owner).to.eq(adminWallet.address);
const tx = await c.call("setOwner", samWallet.address); const tx = await c.call("setOwner", [samWallet.address]);
expect(tx.receipt).to.not.eq(undefined); expect(tx.receipt).to.not.eq(undefined);
const owner2 = await c.call("owner"); const owner2 = await c.call("owner");
expect(owner2).to.eq(samWallet.address); expect(owner2).to.eq(samWallet.address);
@@ -123,7 +123,7 @@ describe("Custom Contracts", async () => {
invariant(c, "Contract undefined"); invariant(c, "Contract undefined");
try { try {
await c.call("setOwner", samWallet.address, { await c.call("setOwner", [samWallet.address], {
value: ethers.utils.parseEther("0.1"), value: ethers.utils.parseEther("0.1"),
}); });
} catch (e) { } catch (e) {
@@ -131,14 +131,17 @@ describe("Custom Contracts", async () => {
} }
try { try {
await c.call("setOwner", samWallet.address, { await c.call("setOwner", [
somObj: "foo", samWallet.address,
}); {
somObj: "foo",
},
]);
} catch (e) { } catch (e) {
expectError(e, "requires 1 arguments, but 2 were provided"); expectError(e, "requires 1 arguments, but 2 were provided");
} }
const tx = await c.call("setOwner", samWallet.address, { const tx = await c.call("setOwner", [samWallet.address], {
gasLimit: 300_000, gasLimit: 300_000,
}); });
expect(tx.receipt).to.not.eq(undefined); expect(tx.receipt).to.not.eq(undefined);
+26 -22
View File
@@ -37,17 +37,19 @@ describe("Error Handling", async () => {
const marketplace = await sdk.getContract(marketplaceAddress); const marketplace = await sdk.getContract(marketplaceAddress);
try { try {
await marketplace.call("createListing", { await marketplace.call("createListing", [
assetContract: collectionAddress, {
tokenId: 0, assetContract: collectionAddress,
startTime: 1000000000000, tokenId: 0,
secondsUntilEndTime: 10000000000000, startTime: 1000000000000,
quantityToList: 1, secondsUntilEndTime: 10000000000000,
currencyToAccept: "0x0000000000000000000000000000000000000000", quantityToList: 1,
reservePricePerToken: 0, currencyToAccept: "0x0000000000000000000000000000000000000000",
buyoutPricePerToken: 0, reservePricePerToken: 0,
listingType: 0, buyoutPricePerToken: 0,
}); listingType: 0,
},
]);
expect.fail(); expect.fail();
} catch (err) { } catch (err) {
// In this case, call static should go through before sendTransaction // In this case, call static should go through before sendTransaction
@@ -75,17 +77,19 @@ describe("Error Handling", async () => {
try { try {
await marketplace.call( await marketplace.call(
"createListing", "createListing",
{ [
assetContract: collectionAddress, {
tokenId: 0, assetContract: collectionAddress,
startTime: 1000000000000, tokenId: 0,
secondsUntilEndTime: 10000000000000, startTime: 1000000000000,
quantityToList: 1, secondsUntilEndTime: 10000000000000,
currencyToAccept: "0x0000000000000000000000000000000000000000", quantityToList: 1,
reservePricePerToken: 0, currencyToAccept: "0x0000000000000000000000000000000000000000",
buyoutPricePerToken: 0, reservePricePerToken: 0,
listingType: 0, buyoutPricePerToken: 0,
}, listingType: 0,
},
],
{ {
gasLimit: 800000, gasLimit: 800000,
}, },
+2 -2
View File
@@ -2,7 +2,7 @@ import { SmartContract, Token } from "../../src/evm";
import { sdk, signers } from "./before-setup"; import { sdk, signers } from "./before-setup";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { TokenERC20__factory } from "@thirdweb-dev/contracts-js"; import { TokenERC20__factory } from "@thirdweb-dev/contracts-js";
import { getContract, getContractFromAbi } from "@thirdweb-dev/sdk"; import { getContract, getContractFromAbi } from "../../src";
import { expect } from "chai"; import { expect } from "chai";
describe("Functions", async () => { describe("Functions", async () => {
@@ -22,7 +22,7 @@ describe("Functions", async () => {
abi: TokenERC20__factory.abi, abi: TokenERC20__factory.abi,
network: adminWallet, network: adminWallet,
}); });
const balance = await contract.call("balanceOf", adminWallet.address); const balance = await contract.call("balanceOf", [adminWallet.address]);
expect(balance.toString()).to.equal("0"); expect(balance.toString()).to.equal("0");
}); });
+6 -9
View File
@@ -126,21 +126,18 @@ describe("Marketplace V3", async () => {
]); ]);
tokenAddress = customTokenContract.getAddress(); tokenAddress = customTokenContract.getAddress();
await marketplaceContract.call( await marketplaceContract.call("grantRole", [
"grantRole",
ethers.utils.solidityKeccak256(["string"], ["LISTER_ROLE"]), ethers.utils.solidityKeccak256(["string"], ["LISTER_ROLE"]),
adminWallet.address, adminWallet.address,
); ]);
await marketplaceContract.call( await marketplaceContract.call("grantRole", [
"grantRole",
ethers.utils.solidityKeccak256(["string"], ["ASSET_ROLE"]), ethers.utils.solidityKeccak256(["string"], ["ASSET_ROLE"]),
dummyBundleContract.getAddress(), dummyBundleContract.getAddress(),
); ]);
await marketplaceContract.call( await marketplaceContract.call("grantRole", [
"grantRole",
ethers.utils.solidityKeccak256(["string"], ["ASSET_ROLE"]), ethers.utils.solidityKeccak256(["string"], ["ASSET_ROLE"]),
dummyNftContract.getAddress(), dummyNftContract.getAddress(),
); ]);
}); });
const createDirectListing = async ( const createDirectListing = async (
+7 -5
View File
@@ -507,11 +507,13 @@ describe("Publishing", async () => {
const uri = await c.call("contractUri"); const uri = await c.call("contractUri");
expect(uri).to.eq(ethers.utils.hexZeroPad("0x1234", 32)); expect(uri).to.eq(ethers.utils.hexZeroPad("0x1234", 32));
const tx = await c.call("updateStruct", { const tx = await c.call("updateStruct", [
aNumber: 123, {
aString: ethers.utils.hexZeroPad("0x1234", 32), aNumber: 123,
anArray: [adminWallet.address, samWallet.address], aString: ethers.utils.hexZeroPad("0x1234", 32),
}); anArray: [adminWallet.address, samWallet.address],
},
]);
expect(tx).to.not.eq(undefined); expect(tx).to.not.eq(undefined);
}); });
+2 -3
View File
@@ -21,8 +21,7 @@ describe("Tiered Drop Contract", async () => {
const tieredDrop = await sdk.getContract(address); const tieredDrop = await sdk.getContract(address);
const walletAddress = await sdk.wallet.getAddress(); const walletAddress = await sdk.wallet.getAddress();
await tieredDrop.call( await tieredDrop.call("initialize", [
"initialize",
walletAddress, // defaultAdmin walletAddress, // defaultAdmin
"Tiered Drop #1", // name "Tiered Drop #1", // name
"TD", // symbol "TD", // symbol
@@ -31,7 +30,7 @@ describe("Tiered Drop Contract", async () => {
walletAddress, // saleRecipient walletAddress, // saleRecipient
walletAddress, // royaltyRecipient walletAddress, // royaltyRecipient
0, // royaltyBps 0, // royaltyBps
); ]);
return tieredDrop; return tieredDrop;
} }
+6
View File
@@ -1,5 +1,11 @@
# @thirdweb-dev/storage # @thirdweb-dev/storage
## 1.1.2
### Patch Changes
- [#843](https://github.com/thirdweb-dev/js/pull/843) [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d) Thanks [@jnsdls](https://github.com/jnsdls)! - uploads to IPFS should start significantly faster due to a change in the re-upload detection
## 1.1.1 ## 1.1.1
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/storage", "name": "@thirdweb-dev/storage",
"version": "1.1.1", "version": "1.1.2",
"main": "dist/thirdweb-dev-storage.cjs.js", "main": "dist/thirdweb-dev-storage.cjs.js",
"module": "dist/thirdweb-dev-storage.esm.js", "module": "dist/thirdweb-dev-storage.esm.js",
"browser": { "browser": {
+4
View File
@@ -69,6 +69,10 @@ export async function getCID(
export async function isUploaded(cid: string) { export async function isUploaded(cid: string) {
const res = await fetch(`${DEFAULT_GATEWAY_URLS["ipfs://"][0]}${cid}`, { const res = await fetch(`${DEFAULT_GATEWAY_URLS["ipfs://"][0]}${cid}`, {
method: "HEAD", method: "HEAD",
headers: {
// tell the gateway to skip fetching from origin in order to fail fast on 404s and just re-upload in those cases
"x-skip-origin": "true",
},
}); });
return res.ok; return res.ok;
} }
+10
View File
@@ -1,5 +1,15 @@
# @thirdweb-dev/unity-js-bridge # @thirdweb-dev/unity-js-bridge
## 0.2.20
### Patch Changes
- Updated dependencies [[`b7fcae6e`](https://github.com/thirdweb-dev/js/commit/b7fcae6e40dade7a239b1a6afb1cd996c8f89910), [`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d)]:
- @thirdweb-dev/sdk@3.10.6
- @thirdweb-dev/storage@1.1.2
- @thirdweb-dev/wallets@0.2.11
- @thirdweb-dev/auth@3.0.10
## 0.2.19 ## 0.2.19
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/unity-js-bridge", "name": "@thirdweb-dev/unity-js-bridge",
"version": "0.2.19", "version": "0.2.20",
"main": "dist/thirdweb-unity-bridge.js", "main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge", "repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0", "license": "Apache-2.0",
+7
View File
@@ -1,5 +1,12 @@
# @thirdweb-dev/wallets # @thirdweb-dev/wallets
## 0.2.11
### Patch Changes
- Updated dependencies [[`839fce1f`](https://github.com/thirdweb-dev/js/commit/839fce1f6f2747d6102033b26c292294e908f75d)]:
- @thirdweb-dev/chains@0.1.9
## 0.2.10 ## 0.2.10
### Patch Changes ### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@thirdweb-dev/wallets", "name": "@thirdweb-dev/wallets",
"version": "0.2.10", "version": "0.2.11",
"main": "dist/thirdweb-dev-wallets.cjs.js", "main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js", "module": "dist/thirdweb-dev-wallets.esm.js",
"types": "dist/thirdweb-dev-wallets.cjs.d.ts", "types": "dist/thirdweb-dev-wallets.cjs.d.ts",