Compare commits

..
Author SHA1 Message Date
github-actions[bot]GitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
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 DanielsandGitHub 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 TankandGitHub 1f2df55b67 react-core: add useNetwork hook (#841) 2023-03-30 20:03:12 +00:00
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
## 3.0.10
### Patch Changes
- Updated dependencies []:
- @thirdweb-dev/wallets@0.2.11
## 3.0.9
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "3.0.9",
"version": "3.0.10",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
+6
View File
@@ -1,5 +1,11 @@
# @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
### Patch Changes
+1 -1
View File
@@ -27,7 +27,7 @@ export default {
{
"name": "Shardeum Scan",
"url": "https://explorer-liberty10.shardeum.org",
"standard": "none"
"standard": "EIP3091"
}
],
"redFlags": [
+1 -1
View File
@@ -27,7 +27,7 @@ export default {
{
"name": "Shardeum Scan",
"url": "https://explorer-liberty20.shardeum.org",
"standard": "none"
"standard": "EIP3091"
}
],
"redFlags": [
+1 -1
View File
@@ -27,7 +27,7 @@ export default {
{
"name": "Shardeum Scan",
"url": "https://explorer-sphinx.shardeum.org",
"standard": "none"
"standard": "EIP3091"
}
],
"redFlags": [
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/chains",
"version": "0.1.8",
"version": "0.1.9",
"main": "dist/thirdweb-dev-chains.cjs.js",
"module": "dist/thirdweb-dev-chains.esm.js",
"browser": {
+8
View File
@@ -1,5 +1,13 @@
# 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
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.10.5",
"version": "0.10.6",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+45
View File
@@ -1,5 +1,50 @@
# @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
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"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",
"author": "thirdweb eng <[email protected]>",
"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(
contract: RequiredParam<ValidContractInstance>,
functionName: RequiredParam<string>,
...args: unknown[] | [...unknown[], CallOverrides]
args?: unknown[],
overrides?: CallOverrides,
) {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.call(contractAddress, functionName, args),
cacheKeys.contract.call(contractAddress, functionName, args, overrides),
() => {
requiredParamInvariant(contract, "contract must be defined");
requiredParamInvariant(functionName, "function name must be provided");
return (
contract.call as (
functionName: string,
...args: unknown[] | [...unknown[], CallOverrides]
args?: unknown[],
overrides?: CallOverrides,
) => Promise<any>
)(functionName, ...args);
)(functionName, args, overrides);
},
{
enabled: !!contract && !!functionName,
@@ -560,23 +562,17 @@ export function useContractWrite(
const queryClient = useQueryClient();
return useMutation(
async (callParams?: unknown[] | [...unknown[], CallOverrides]) => {
async (args?: unknown[], overrides?: CallOverrides) => {
requiredParamInvariant(contract, "contract must be defined");
requiredParamInvariant(functionName, "function name must be provided");
if (!callParams?.length) {
return (
contract.call as (
functionName: string,
...args: unknown[] | [...unknown[], CallOverrides]
) => Promise<any>
)(functionName);
}
return (
contract.call as (
functionName: string,
...args: unknown[] | [...unknown[], CallOverrides]
args?: unknown[],
overrides?: CallOverrides,
) => Promise<any>
)(functionName, ...callParams);
)(functionName, args, overrides);
},
{
onSettled: () =>
+1
View File
@@ -17,6 +17,7 @@ export {
useSwitchChain,
useWallets,
} from "../core/hooks/wallet-hooks";
export { useNetwork } from "../core/hooks/useNetwork";
export { useThirdwebWallet } from "../core/providers/thirdweb-wallet-provider";
// connected wallet hooks
@@ -7,7 +7,7 @@ import type {
QueryAllParams,
SUPPORTED_CHAIN_ID,
} from "@thirdweb-dev/sdk";
import { BigNumberish, constants } from "ethers";
import { BigNumberish, CallOverrides, constants } from "ethers";
const TW_CACHE_KEY_PREFIX = "tw-cache";
@@ -108,8 +108,15 @@ export const cacheKeys = {
call: (
contractAddress: RequiredParam<ContractAddress>,
functionName: RequiredParam<string>,
args: unknown[],
) => createContractCacheKey(contractAddress, ["call", functionName, args]),
args?: unknown[],
overrides?: CallOverrides,
) =>
createContractCacheKey(contractAddress, [
"call",
functionName,
args,
overrides,
]),
app: {
get: (contractAddress: RequiredParam<ContractAddress>) =>
@@ -39,13 +39,14 @@ export function programQuery<TProgramType extends ProgramType>(
return {
queryKey: neverPersist(
createSOLQueryKeyWithNetwork(
["program-instance", address] as const,
["program-instance", { address, type }] as const,
network || null,
),
),
queryFn: (async () => {
requiredParamInvariant(sdk, "sdk is required");
requiredParamInvariant(address, "Address is required");
// if the type is not passed in explicitly then we'll try to resolve it
if (!type) {
// why do we call `fetchQuery` here instead of calling the sdk directly?
@@ -1,5 +1,7 @@
# @thirdweb-dev/react-native-compat
## 0.2.2
## 0.2.1
## 0.2.0
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@thirdweb-dev/react-native-compat",
"description": "Shims for Thirdweb in React Native Projects",
"version": "0.2.1",
"version": "0.2.2",
"author": "thirdweb eng <[email protected]>",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-native-compat",
"license": "Apache-2.0",
+11
View File
@@ -1,5 +1,16 @@
# @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
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"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",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+10
View File
@@ -1,5 +1,15 @@
# @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
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "3.11.1",
"version": "3.11.2",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
+34
View File
@@ -1,5 +1,39 @@
# @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
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/sdk",
"version": "3.10.5",
"version": "3.10.6",
"description": "The main thirdweb SDK.",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
"license": "Apache-2.0",
@@ -414,13 +414,9 @@ export class EditionDrop extends StandardErc1155<PrebuiltEditionDrop> {
TMethod extends keyof PrebuiltEditionDrop["functions"] = keyof PrebuiltEditionDrop["functions"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<PrebuiltEditionDrop["functions"][TMethod]>)
| [
...(any[] & Parameters<PrebuiltEditionDrop["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<PrebuiltEditionDrop["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<TokenERC1155["functions"][TMethod]>)
| [
...(any[] & Parameters<TokenERC1155["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<TokenERC1155["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<MarketplaceContract["functions"][TMethod]>)
| [
...(any[] & Parameters<MarketplaceContract["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<MarketplaceContract["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<MarketplaceV3Contract["functions"][TMethod]>)
| [
...(any[] & Parameters<MarketplaceV3Contract["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<MarketplaceV3Contract["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<MultiwrapContract["functions"][TMethod]>)
| [
...(any[] & Parameters<MultiwrapContract["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<MultiwrapContract["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<TokenERC721["functions"][TMethod]>)
| [
...(any[] & Parameters<TokenERC721["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<TokenERC721["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<PrebuiltNFTDrop["functions"][TMethod]>)
| [
...(any[] & Parameters<PrebuiltNFTDrop["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<PrebuiltNFTDrop["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<PackContract["functions"][TMethod]>)
| [
...(any[] & Parameters<PackContract["functions"][TMethod]>),
CallOverrides,
]
args?: any[] & Parameters<PackContract["functions"][TMethod]>,
overrides?: CallOverrides,
): Promise<any> {
return this.contractWrapper.call(functionName, ...args);
return this.contractWrapper.call(functionName, args, overrides);
}
private detectVrf() {
@@ -509,13 +509,9 @@ export class SignatureDrop extends StandardErc721<SignatureDropContract> {
TMethod extends keyof SignatureDropContract["functions"] = keyof SignatureDropContract["functions"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<SignatureDropContract["functions"][TMethod]>)
| [
...(any[] & Parameters<SignatureDropContract["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<SignatureDropContract["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<SplitContract["functions"][TMethod]>)
| [
...(any[] & Parameters<SplitContract["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<SplitContract["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<PrebuiltTokenDrop["functions"][TMethod]>)
| [
...(any[] & Parameters<PrebuiltTokenDrop["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<PrebuiltTokenDrop["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<TokenERC20["functions"][TMethod]>)
| [
...(any[] & Parameters<TokenERC20["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<TokenERC20["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<VoteERC20["functions"][TMethod]>)
| [
...(any[] & Parameters<VoteERC20["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<VoteERC20["functions"][TMethod]>,
overrides?: CallOverrides,
): 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"],
>(
functionName: string & TMethod,
...args:
| (any[] & Parameters<TContract["functions"][TMethod]>)
| [
...(any[] & Parameters<TContract["functions"][TMethod]>),
CallOverrides,
]
args?: Parameters<TContract["functions"][TMethod]>,
overrides?: CallOverrides,
): 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(
functionName: string,
...args: unknown[] | [...unknown[], CallOverrides]
args: unknown[] = [],
overrides?: CallOverrides,
): Promise<any> {
// parse last arg as tx options if present
let txOptions: CallOverrides | undefined;
try {
if (args.length > 0 && typeof args[args.length - 1] === "object") {
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
}
let txOptions: CallOverrides | undefined = overrides
? await CallOverrideSchema.parseAsync(overrides)
: undefined;
const functions = extractFunctionsFromAbi(AbiSchema.parse(this.abi)).filter(
(f) => f.name === functionName,
@@ -40,6 +40,7 @@ export class Registry {
const candyMachine = await this.metaplex
.candyMachinesV2()
.findByAddress({ address: new PublicKey(address) });
if (candyMachine) {
return "nft-drop";
}
+9 -6
View File
@@ -107,7 +107,7 @@ describe("Custom Contracts", async () => {
const owner = await c.call("owner");
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);
const owner2 = await c.call("owner");
expect(owner2).to.eq(samWallet.address);
@@ -123,7 +123,7 @@ describe("Custom Contracts", async () => {
invariant(c, "Contract undefined");
try {
await c.call("setOwner", samWallet.address, {
await c.call("setOwner", [samWallet.address], {
value: ethers.utils.parseEther("0.1"),
});
} catch (e) {
@@ -131,14 +131,17 @@ describe("Custom Contracts", async () => {
}
try {
await c.call("setOwner", samWallet.address, {
somObj: "foo",
});
await c.call("setOwner", [
samWallet.address,
{
somObj: "foo",
},
]);
} catch (e) {
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,
});
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);
try {
await marketplace.call("createListing", {
assetContract: collectionAddress,
tokenId: 0,
startTime: 1000000000000,
secondsUntilEndTime: 10000000000000,
quantityToList: 1,
currencyToAccept: "0x0000000000000000000000000000000000000000",
reservePricePerToken: 0,
buyoutPricePerToken: 0,
listingType: 0,
});
await marketplace.call("createListing", [
{
assetContract: collectionAddress,
tokenId: 0,
startTime: 1000000000000,
secondsUntilEndTime: 10000000000000,
quantityToList: 1,
currencyToAccept: "0x0000000000000000000000000000000000000000",
reservePricePerToken: 0,
buyoutPricePerToken: 0,
listingType: 0,
},
]);
expect.fail();
} catch (err) {
// In this case, call static should go through before sendTransaction
@@ -75,17 +77,19 @@ describe("Error Handling", async () => {
try {
await marketplace.call(
"createListing",
{
assetContract: collectionAddress,
tokenId: 0,
startTime: 1000000000000,
secondsUntilEndTime: 10000000000000,
quantityToList: 1,
currencyToAccept: "0x0000000000000000000000000000000000000000",
reservePricePerToken: 0,
buyoutPricePerToken: 0,
listingType: 0,
},
[
{
assetContract: collectionAddress,
tokenId: 0,
startTime: 1000000000000,
secondsUntilEndTime: 10000000000000,
quantityToList: 1,
currencyToAccept: "0x0000000000000000000000000000000000000000",
reservePricePerToken: 0,
buyoutPricePerToken: 0,
listingType: 0,
},
],
{
gasLimit: 800000,
},
+2 -2
View File
@@ -2,7 +2,7 @@ import { SmartContract, Token } from "../../src/evm";
import { sdk, signers } from "./before-setup";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { TokenERC20__factory } from "@thirdweb-dev/contracts-js";
import { getContract, getContractFromAbi } from "@thirdweb-dev/sdk";
import { getContract, getContractFromAbi } from "../../src";
import { expect } from "chai";
describe("Functions", async () => {
@@ -22,7 +22,7 @@ describe("Functions", async () => {
abi: TokenERC20__factory.abi,
network: adminWallet,
});
const balance = await contract.call("balanceOf", adminWallet.address);
const balance = await contract.call("balanceOf", [adminWallet.address]);
expect(balance.toString()).to.equal("0");
});
+6 -9
View File
@@ -126,21 +126,18 @@ describe("Marketplace V3", async () => {
]);
tokenAddress = customTokenContract.getAddress();
await marketplaceContract.call(
"grantRole",
await marketplaceContract.call("grantRole", [
ethers.utils.solidityKeccak256(["string"], ["LISTER_ROLE"]),
adminWallet.address,
);
await marketplaceContract.call(
"grantRole",
]);
await marketplaceContract.call("grantRole", [
ethers.utils.solidityKeccak256(["string"], ["ASSET_ROLE"]),
dummyBundleContract.getAddress(),
);
await marketplaceContract.call(
"grantRole",
]);
await marketplaceContract.call("grantRole", [
ethers.utils.solidityKeccak256(["string"], ["ASSET_ROLE"]),
dummyNftContract.getAddress(),
);
]);
});
const createDirectListing = async (
+7 -5
View File
@@ -507,11 +507,13 @@ describe("Publishing", async () => {
const uri = await c.call("contractUri");
expect(uri).to.eq(ethers.utils.hexZeroPad("0x1234", 32));
const tx = await c.call("updateStruct", {
aNumber: 123,
aString: ethers.utils.hexZeroPad("0x1234", 32),
anArray: [adminWallet.address, samWallet.address],
});
const tx = await c.call("updateStruct", [
{
aNumber: 123,
aString: ethers.utils.hexZeroPad("0x1234", 32),
anArray: [adminWallet.address, samWallet.address],
},
]);
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 walletAddress = await sdk.wallet.getAddress();
await tieredDrop.call(
"initialize",
await tieredDrop.call("initialize", [
walletAddress, // defaultAdmin
"Tiered Drop #1", // name
"TD", // symbol
@@ -31,7 +30,7 @@ describe("Tiered Drop Contract", async () => {
walletAddress, // saleRecipient
walletAddress, // royaltyRecipient
0, // royaltyBps
);
]);
return tieredDrop;
}
+6
View File
@@ -1,5 +1,11 @@
# @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
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/storage",
"version": "1.1.1",
"version": "1.1.2",
"main": "dist/thirdweb-dev-storage.cjs.js",
"module": "dist/thirdweb-dev-storage.esm.js",
"browser": {
+4
View File
@@ -69,6 +69,10 @@ export async function getCID(
export async function isUploaded(cid: string) {
const res = await fetch(`${DEFAULT_GATEWAY_URLS["ipfs://"][0]}${cid}`, {
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;
}
+10
View File
@@ -1,5 +1,15 @@
# @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
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/unity-js-bridge",
"version": "0.2.19",
"version": "0.2.20",
"main": "dist/thirdweb-unity-bridge.js",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
"license": "Apache-2.0",
+7
View File
@@ -1,5 +1,12 @@
# @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
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/wallets",
"version": "0.2.10",
"version": "0.2.11",
"main": "dist/thirdweb-dev-wallets.cjs.js",
"module": "dist/thirdweb-dev-wallets.esm.js",
"types": "dist/thirdweb-dev-wallets.cjs.d.ts",