Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85dd18e8f0 | ||
|
|
ec1f2324c7 | ||
|
|
b59a31c365 | ||
|
|
d29f7e78f0 | ||
|
|
3e2b392b6b | ||
|
|
cf96333fa2 | ||
|
|
4213cfee77 |
@@ -1,5 +1,18 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.9.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`ec1f232`](https://github.com/thirdweb-dev/js/commit/ec1f2324c7a0e58c2d2a209cfe0d194807ba5b70), [`d29f7e7`](https://github.com/thirdweb-dev/js/commit/d29f7e78f09063630e812dd41164d8a41d4f97dd)]:
|
||||
- @thirdweb-dev/sdk@3.7.4
|
||||
|
||||
## 0.9.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#537](https://github.com/thirdweb-dev/js/pull/537) [`cf96333`](https://github.com/thirdweb-dev/js/commit/cf96333fa2f46a4a73a822a0b1248891cc890267) Thanks [@adam-maj](https://github.com/adam-maj)! - Fix cache error on windows OS
|
||||
|
||||
## 0.9.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.9.14",
|
||||
"version": "0.9.16",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -82,8 +82,12 @@ const main = async () => {
|
||||
const versionInfo = await notifier.fetchInfo();
|
||||
versionSpinner.stop();
|
||||
|
||||
// Set cache to prevent checking for updates again for 24 hours
|
||||
cache.set("last-version-check", new Date().toISOString());
|
||||
try {
|
||||
// Set cache to prevent checking for updates again for 24 hours
|
||||
cache.set("last-version-check", new Date().toISOString());
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
|
||||
if (versionInfo.type !== "latest") {
|
||||
const res = await prompts({
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 3.7.4
|
||||
|
||||
## 3.7.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "3.7.3",
|
||||
"version": "3.7.4",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 3.7.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#470](https://github.com/thirdweb-dev/js/pull/470) [`b59a31c`](https://github.com/thirdweb-dev/js/commit/b59a31c365380c4dc9aed8d7678d46b4b21a029d) Thanks [@JustinTime42](https://github.com/JustinTime42)! - Added support for displaying 3d model NFTs
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/react-core@3.7.4
|
||||
|
||||
## 3.7.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "3.7.3",
|
||||
"version": "3.7.4",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
@@ -102,6 +102,7 @@
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.10.0",
|
||||
"@emotion/styled": "^11.10.0",
|
||||
"@google/model-viewer": "^2.1.1",
|
||||
"@react-icons/all-files": "^4.1.0",
|
||||
"@safe-global/safe-core-sdk": "^3.2.0",
|
||||
"@safe-global/safe-ethers-adapters": "0.1.0-alpha.13",
|
||||
|
||||
@@ -9,9 +9,19 @@ import {
|
||||
CarbonPlayFilledAlt,
|
||||
} from "./Icons";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import React, {
|
||||
ReactNode,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
lazy,
|
||||
Suspense,
|
||||
} from "react";
|
||||
import useDimensions from "react-cool-dimensions";
|
||||
|
||||
const ModelViewer = lazy(() => import("./ModelViewer"));
|
||||
|
||||
export interface SharedMediaProps {
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
@@ -25,6 +35,8 @@ export interface SharedMediaProps {
|
||||
* Show the media controls (where applicable) (default false)
|
||||
*/
|
||||
controls?: HTMLVideoElement["controls"];
|
||||
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,6 +57,8 @@ export interface MediaRendererProps extends SharedMediaProps {
|
||||
* The media poster image uri. (if applicable)
|
||||
*/
|
||||
poster?: string | null;
|
||||
width?: string;
|
||||
height?: string;
|
||||
}
|
||||
|
||||
interface PlayButtonProps {
|
||||
@@ -399,6 +413,7 @@ LinkPlayer.displayName = "LinkPlayer";
|
||||
* This component can be used to render any media type, including image, audio, video, and html files.
|
||||
* Its convenient for rendering NFT media files, as these can be a variety of different types.
|
||||
* The component falls back to a external link if the media type is not supported.
|
||||
* The default size is 300px by 300px, but this can be changed using the `width` and `height` props.
|
||||
*
|
||||
* Props: {@link MediaRendererProps}
|
||||
*
|
||||
@@ -420,10 +435,10 @@ export const MediaRenderer = React.forwardRef<
|
||||
MediaRendererProps
|
||||
>(
|
||||
(
|
||||
{ src, poster, alt, requireInteraction = false, style, ...restProps },
|
||||
{ src, poster, alt, requireInteraction = false, width = "300px", height = "300px", style, ...restProps },
|
||||
ref,
|
||||
) => {
|
||||
const mergedStyle: React.CSSProperties = { objectFit: "contain", ...style };
|
||||
const mergedStyle: React.CSSProperties = { objectFit: "contain", width, height, ...style };
|
||||
const videoOrImageSrc = useResolvedMediaType(src ?? undefined);
|
||||
const possiblePosterSrc = useResolvedMediaType(poster ?? undefined);
|
||||
if (!videoOrImageSrc.mimeType) {
|
||||
@@ -445,6 +460,30 @@ export const MediaRenderer = React.forwardRef<
|
||||
{...restProps}
|
||||
/>
|
||||
);
|
||||
} else if (videoOrImageSrc.mimeType.startsWith("model")) {
|
||||
return (
|
||||
<Suspense
|
||||
fallback={
|
||||
poster ? (
|
||||
<img
|
||||
style={mergedStyle}
|
||||
src={poster}
|
||||
alt={alt}
|
||||
ref={ref as unknown as React.LegacyRef<HTMLImageElement>}
|
||||
{...restProps}
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
<ModelViewer
|
||||
style={mergedStyle}
|
||||
src={videoOrImageSrc.url || ""}
|
||||
poster={poster}
|
||||
alt={alt}
|
||||
{...restProps}
|
||||
/>
|
||||
</Suspense>
|
||||
);
|
||||
} else if (shouldRenderVideoTag(videoOrImageSrc.mimeType)) {
|
||||
return (
|
||||
<VideoPlayer
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { MediaRendererProps } from "./MediaRenderer";
|
||||
import "@google/model-viewer";
|
||||
import type { ModelViewerElement } from "@google/model-viewer";
|
||||
import React from "react";
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
"model-viewer": Partial<ModelViewerElement>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const ModelViewer = React.forwardRef<HTMLDivElement, MediaRendererProps>(
|
||||
({ src, alt, poster, style }, ref) => {
|
||||
return (
|
||||
<div style={{ ...style }} ref={ref}>
|
||||
{src ? (
|
||||
<model-viewer
|
||||
src={src}
|
||||
alt={alt || "3D Model"}
|
||||
camera-controls
|
||||
poster={poster ? poster : null}
|
||||
style={{ width: '100%', height: '100%'} as CSSStyleDeclaration}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
ModelViewer.displayName = "ModelViewer";
|
||||
|
||||
export default ModelViewer;
|
||||
@@ -10,10 +10,15 @@ export interface ThirdwebNftMediaProps extends SharedMediaProps {
|
||||
* The NFT metadata of the NFT returned by the thirdweb sdk.
|
||||
*/
|
||||
metadata: NFTMetadata;
|
||||
width?: string;
|
||||
height?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* This component can be used to render NFTs from the thirdweb SDK.
|
||||
* It will render the animation_url if it exists, otherwise it will render the image.
|
||||
* The default size is 300px by 300px, but this can be changed using the `width` and `height` props.
|
||||
*
|
||||
* Props: {@link ThirdwebNftMediaProps}
|
||||
*
|
||||
* @example
|
||||
@@ -38,13 +43,16 @@ export interface ThirdwebNftMediaProps extends SharedMediaProps {
|
||||
export const ThirdwebNftMedia = React.forwardRef<
|
||||
HTMLMediaElement,
|
||||
ThirdwebNftMediaProps
|
||||
>(({ metadata, ...props }, ref) => {
|
||||
>(({ metadata, width = "300px", height = "300px", style, ...props }, ref) => {
|
||||
return (
|
||||
<MediaRenderer
|
||||
src={metadata.animation_url || metadata.image}
|
||||
poster={metadata.image}
|
||||
alt={metadata.name?.toString() || ""}
|
||||
ref={ref}
|
||||
width={width}
|
||||
height={height}
|
||||
style={{ ...style }}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,13 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 3.7.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#542](https://github.com/thirdweb-dev/js/pull/542) [`ec1f232`](https://github.com/thirdweb-dev/js/commit/ec1f2324c7a0e58c2d2a209cfe0d194807ba5b70) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Solana - Expose getTransaction pagination options + transactions for given wallet
|
||||
|
||||
- [#540](https://github.com/thirdweb-dev/js/pull/540) [`d29f7e7`](https://github.com/thirdweb-dev/js/commit/d29f7e78f09063630e812dd41164d8a41d4f97dd) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - expose `getMintTransaction()` for fine grain control on mint calls
|
||||
|
||||
## 3.7.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "3.7.3",
|
||||
"version": "3.7.4",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -258,6 +258,19 @@ export class Edition extends StandardErc1155<TokenERC1155> {
|
||||
return this.erc1155.mintTo(to, metadataWithSupply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a mint transaction without executing it.
|
||||
* This is useful for estimating the gas cost of a mint transaction, overriding transaction options and having fine grained control over the transaction execution.
|
||||
* @param receiver - Address you want to send the token to
|
||||
* @param metadataWithSupply - The metadata of the NFT you want to mint
|
||||
*/
|
||||
public async getMintTransaction(
|
||||
receiver: string,
|
||||
metadataWithSupply: EditionMetadataOrUri,
|
||||
) {
|
||||
return this.erc1155.getMintTransaction(receiver, metadataWithSupply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase the supply of an existing NFT and mint it to the connected wallet
|
||||
*
|
||||
|
||||
@@ -229,6 +229,19 @@ export class NFTCollection extends StandardErc721<TokenERC721> {
|
||||
return this.erc721.mintTo(walletAddress, metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a mint transaction without executing it.
|
||||
* This is useful for estimating the gas cost of a mint transaction, overriding transaction options and having fine grained control over the transaction execution.
|
||||
* @param receiver - Address you want to send the token to
|
||||
* @param metadata - The metadata of the NFT you want to mint
|
||||
*/
|
||||
public async getMintTransaction(
|
||||
receiver: string,
|
||||
metadata: NFTMetadataOrUri,
|
||||
) {
|
||||
return this.erc721.getMintTransaction(receiver, metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mint Many unique NFTs
|
||||
*
|
||||
|
||||
@@ -186,6 +186,16 @@ export class Token extends StandardErc20<TokenERC20> {
|
||||
return this.erc20.mintTo(to, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a mint transaction without executing it.
|
||||
* This is useful for estimating the gas cost of a mint transaction, overriding transaction options and having fine grained control over the transaction execution.
|
||||
* @param receiver - Address you want to send the token to
|
||||
* @param amount - The amount of tokens you want to mint
|
||||
*/
|
||||
public async getMintTransaction(to: string, amount: Amount) {
|
||||
return this.erc20.getMintTransaction(to, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mint Tokens To Many Wallets
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ import { FEATURE_EDITION_MINTABLE } from "../../constants/erc1155-features";
|
||||
import { EditionMetadataOrUri } from "../../schema";
|
||||
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||
import { TransactionResultWithId } from "../types";
|
||||
import { TransactionTask } from "./TransactionTask";
|
||||
import { ContractWrapper } from "./contract-wrapper";
|
||||
import { Erc1155 } from "./erc-1155";
|
||||
import { Erc1155BatchMintable } from "./erc-1155-batch-mintable";
|
||||
@@ -77,16 +78,8 @@ export class Erc1155Mintable implements DetectableFeature {
|
||||
to: string,
|
||||
metadataWithSupply: EditionMetadataOrUri,
|
||||
): Promise<TransactionResultWithId<NFT>> {
|
||||
const uri = await uploadOrExtractURI(
|
||||
metadataWithSupply.metadata,
|
||||
this.storage,
|
||||
);
|
||||
const receipt = await this.contractWrapper.sendTransaction("mintTo", [
|
||||
to,
|
||||
ethers.constants.MaxUint256,
|
||||
uri,
|
||||
metadataWithSupply.supply,
|
||||
]);
|
||||
const tx = await this.getMintTransaction(to, metadataWithSupply);
|
||||
const { receipt } = await tx.execute();
|
||||
const event = this.contractWrapper.parseLogs<TransferSingleEvent>(
|
||||
"TransferSingle",
|
||||
receipt?.logs,
|
||||
@@ -102,6 +95,21 @@ export class Erc1155Mintable implements DetectableFeature {
|
||||
};
|
||||
}
|
||||
|
||||
public async getMintTransaction(
|
||||
to: string,
|
||||
metadataWithSupply: EditionMetadataOrUri,
|
||||
): Promise<TransactionTask> {
|
||||
const uri = await uploadOrExtractURI(
|
||||
metadataWithSupply.metadata,
|
||||
this.storage,
|
||||
);
|
||||
return TransactionTask.make({
|
||||
contractWrapper: this.contractWrapper,
|
||||
functionName: "mintTo",
|
||||
args: [to, ethers.constants.MaxUint256, uri, metadataWithSupply.supply],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase the supply of an existing NFT and mint it to a given wallet address
|
||||
*
|
||||
|
||||
@@ -473,6 +473,22 @@ export class Erc1155<
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a mint transaction without executing it.
|
||||
* This is useful for estimating the gas cost of a mint transaction, overriding transaction options and having fine grained control over the transaction execution.
|
||||
* @param receiver - Address you want to send the token to
|
||||
* @param metadataWithSupply - The metadata of the NFT you want to mint
|
||||
*/
|
||||
public async getMintTransaction(
|
||||
receiver: string,
|
||||
metadataWithSupply: EditionMetadataOrUri,
|
||||
) {
|
||||
return assertEnabled(
|
||||
this.mintable,
|
||||
FEATURE_EDITION_MINTABLE,
|
||||
).getMintTransaction(receiver, metadataWithSupply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase the supply of an existing NFT
|
||||
* @remarks Increase the supply of an existing NFT and mint it to the connected wallet address
|
||||
|
||||
@@ -3,6 +3,7 @@ import { FEATURE_TOKEN_MINTABLE } from "../../constants/erc20-features";
|
||||
import { Amount } from "../../types";
|
||||
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||
import { TransactionResult } from "../types";
|
||||
import { TransactionTask } from "./TransactionTask";
|
||||
import { ContractWrapper } from "./contract-wrapper";
|
||||
import { Erc20 } from "./erc-20";
|
||||
import { Erc20BatchMintable } from "./erc-20-batch-mintable";
|
||||
@@ -47,12 +48,19 @@ export class Erc20Mintable implements DetectableFeature {
|
||||
* ```
|
||||
*/
|
||||
public async to(to: string, amount: Amount): Promise<TransactionResult> {
|
||||
return {
|
||||
receipt: await this.contractWrapper.sendTransaction("mintTo", [
|
||||
to,
|
||||
await this.erc20.normalizeAmount(amount),
|
||||
]),
|
||||
};
|
||||
const tx = await this.getMintTransaction(to, amount);
|
||||
return tx.execute();
|
||||
}
|
||||
|
||||
public async getMintTransaction(
|
||||
to: string,
|
||||
amount: Amount,
|
||||
): Promise<TransactionTask> {
|
||||
return TransactionTask.make({
|
||||
contractWrapper: this.contractWrapper,
|
||||
functionName: "mintTo",
|
||||
args: [to, await this.erc20.normalizeAmount(amount)],
|
||||
});
|
||||
}
|
||||
|
||||
private detectErc20BatchMintable() {
|
||||
|
||||
@@ -376,6 +376,19 @@ export class Erc20<
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a mint transaction without executing it.
|
||||
* This is useful for estimating the gas cost of a mint transaction, overriding transaction options and having fine grained control over the transaction execution.
|
||||
* @param receiver - Address you want to send the token to
|
||||
* @param amount - The amount of tokens you want to mint
|
||||
*/
|
||||
public async getMintTransaction(receiver: string, amount: Amount) {
|
||||
return assertEnabled(
|
||||
this.mintable,
|
||||
FEATURE_TOKEN_MINTABLE,
|
||||
).getMintTransaction(receiver, amount);
|
||||
}
|
||||
|
||||
////// ERC20 BatchMintable Extension //////
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@ import { uploadOrExtractURI } from "../../common/nft";
|
||||
import { FEATURE_NFT_MINTABLE } from "../../constants/erc721-features";
|
||||
import { DetectableFeature } from "../interfaces/DetectableFeature";
|
||||
import { TransactionResultWithId } from "../types";
|
||||
import { TransactionTask } from "./TransactionTask";
|
||||
import { ContractWrapper } from "./contract-wrapper";
|
||||
import { Erc721 } from "./erc-721";
|
||||
import { Erc721BatchMintable } from "./erc-721-batch-mintable";
|
||||
@@ -67,11 +68,8 @@ export class Erc721Mintable implements DetectableFeature {
|
||||
to: string,
|
||||
metadata: NFTMetadataOrUri,
|
||||
): Promise<TransactionResultWithId<NFT>> {
|
||||
const uri = await uploadOrExtractURI(metadata, this.storage);
|
||||
const receipt = await this.contractWrapper.sendTransaction("mintTo", [
|
||||
to,
|
||||
uri,
|
||||
]);
|
||||
const tx = await this.getMintTransaction(to, metadata);
|
||||
const { receipt } = await tx.execute();
|
||||
const event = this.contractWrapper.parseLogs<TransferEvent>(
|
||||
"Transfer",
|
||||
receipt?.logs,
|
||||
@@ -87,6 +85,18 @@ export class Erc721Mintable implements DetectableFeature {
|
||||
};
|
||||
}
|
||||
|
||||
public async getMintTransaction(
|
||||
to: string,
|
||||
metadata: NFTMetadataOrUri,
|
||||
): Promise<TransactionTask> {
|
||||
const uri = await uploadOrExtractURI(metadata, this.storage);
|
||||
return TransactionTask.make({
|
||||
contractWrapper: this.contractWrapper,
|
||||
functionName: "mintTo",
|
||||
args: [to, uri],
|
||||
});
|
||||
}
|
||||
|
||||
private detectErc721BatchMintable(): Erc721BatchMintable | undefined {
|
||||
if (
|
||||
detectContractFeature<IMintableERC721 & IMulticall>(
|
||||
|
||||
@@ -409,6 +409,22 @@ export class Erc721<
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a mint transaction without executing it.
|
||||
* This is useful for estimating the gas cost of a mint transaction, overriding transaction options and having fine grained control over the transaction execution.
|
||||
* @param receiver - Address you want to send the token to
|
||||
* @param metadata - The metadata of the NFT you want to mint
|
||||
*/
|
||||
public async getMintTransaction(
|
||||
receiver: string,
|
||||
metadata: NFTMetadataOrUri,
|
||||
) {
|
||||
return assertEnabled(
|
||||
this.mintable,
|
||||
FEATURE_NFT_MINTABLE,
|
||||
).getMintTransaction(receiver, metadata);
|
||||
}
|
||||
|
||||
////// ERC721 Batch Mintable Extension //////
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
Connection,
|
||||
ParsedAccountData,
|
||||
PublicKey,
|
||||
SignaturesForAddressOptions,
|
||||
TransactionResponse,
|
||||
} from "@solana/web3.js";
|
||||
|
||||
@@ -177,27 +178,38 @@ export class NFTHelper {
|
||||
|
||||
async getTransactions(
|
||||
collectionAddress: string,
|
||||
options?: SignaturesForAddressOptions,
|
||||
): Promise<TransactionResponse[]> {
|
||||
const collectionKey = new PublicKey(collectionAddress);
|
||||
|
||||
// TODO cache signatures <> transactions mapping in memory so pagination doesn't re-request this everytime
|
||||
const allSignatures: ConfirmedSignatureInfo[] = [];
|
||||
// This returns the first 1000, so we need to loop through until we run out of signatures to get.
|
||||
let signatures = await this.metaplex.connection.getSignaturesForAddress(
|
||||
collectionKey,
|
||||
);
|
||||
|
||||
allSignatures.push(...signatures);
|
||||
do {
|
||||
const options = {
|
||||
before: signatures[signatures.length - 1]?.signature,
|
||||
};
|
||||
signatures = await this.metaplex.connection.getSignaturesForAddress(
|
||||
collectionKey,
|
||||
options,
|
||||
if (options) {
|
||||
// only fetch the specified options
|
||||
allSignatures.push(
|
||||
...(await this.metaplex.connection.getSignaturesForAddress(
|
||||
collectionKey,
|
||||
options,
|
||||
)),
|
||||
);
|
||||
} else {
|
||||
// fetch everything
|
||||
// This returns the first 1000, so we need to loop through until we run out of signatures to get.
|
||||
let signatures = await this.metaplex.connection.getSignaturesForAddress(
|
||||
collectionKey,
|
||||
);
|
||||
|
||||
allSignatures.push(...signatures);
|
||||
} while (signatures.length > 0);
|
||||
do {
|
||||
signatures = await this.metaplex.connection.getSignaturesForAddress(
|
||||
collectionKey,
|
||||
{
|
||||
before: signatures[signatures.length - 1]?.signature,
|
||||
},
|
||||
);
|
||||
allSignatures.push(...signatures);
|
||||
} while (signatures.length > 0);
|
||||
}
|
||||
|
||||
let txns: TransactionResponse[] = [];
|
||||
// TODO RPC's will throttle this, need to do some optimizations here
|
||||
@@ -210,13 +222,11 @@ export class NFTHelper {
|
||||
|
||||
txns = [
|
||||
...txns,
|
||||
...(
|
||||
(
|
||||
await this.metaplex.connection.getTransactions(
|
||||
batch.map((s) => s.signature),
|
||||
)
|
||||
).filter((tx) => !!tx) as TransactionResponse[]
|
||||
).reverse(),
|
||||
...((
|
||||
await this.metaplex.connection.getTransactions(
|
||||
batch.map((s) => s.signature),
|
||||
)
|
||||
).filter((tx) => !!tx) as TransactionResponse[]),
|
||||
];
|
||||
}
|
||||
return txns;
|
||||
@@ -225,7 +235,7 @@ export class NFTHelper {
|
||||
async getAllMetadataAddresses(
|
||||
collectionAddress: string,
|
||||
): Promise<PublicKey[]> {
|
||||
const txns = await this.getTransactions(collectionAddress);
|
||||
const txns = (await this.getTransactions(collectionAddress)).reverse();
|
||||
|
||||
return txns
|
||||
.map((tx) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { CurrencyValue } from "../../core/schema/token";
|
||||
import { WalletSigner } from "../types/common";
|
||||
import { toCurrencyValue } from "../utils/token";
|
||||
import { NFTHelper } from "./helpers/nft-helper";
|
||||
import {
|
||||
amount,
|
||||
guestIdentity,
|
||||
@@ -12,7 +13,12 @@ import {
|
||||
SOL,
|
||||
walletAdapterIdentity,
|
||||
} from "@metaplex-foundation/js";
|
||||
import { Keypair, PublicKey } from "@solana/web3.js";
|
||||
import {
|
||||
Keypair,
|
||||
PublicKey,
|
||||
SignaturesForAddressOptions,
|
||||
TransactionResponse,
|
||||
} from "@solana/web3.js";
|
||||
import bs58 from "bs58";
|
||||
import EventEmitter from "eventemitter3";
|
||||
import invariant from "tiny-invariant";
|
||||
@@ -172,6 +178,20 @@ export class UserWallet {
|
||||
return toCurrencyValue(amount(value, SOL));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the all transactions for this program
|
||||
* @beta
|
||||
*/
|
||||
async getTransactions(
|
||||
options?: SignaturesForAddressOptions,
|
||||
): Promise<TransactionResponse[]> {
|
||||
const helper = new NFTHelper(this.metaplex);
|
||||
return helper.getTransactions(
|
||||
this.metaplex.identity().publicKey.toBase58(),
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
private connectToMetaplex(signer: WalletSigner) {
|
||||
invariant(signer, "Wallet is not connected");
|
||||
const plugin = isKeypairSigner(signer)
|
||||
|
||||
@@ -18,7 +18,11 @@ import {
|
||||
toOriginalEditionAccount,
|
||||
TransactionBuilder,
|
||||
} from "@metaplex-foundation/js";
|
||||
import { PublicKey, TransactionResponse } from "@solana/web3.js";
|
||||
import {
|
||||
PublicKey,
|
||||
SignaturesForAddressOptions,
|
||||
TransactionResponse,
|
||||
} from "@solana/web3.js";
|
||||
import { ThirdwebStorage } from "@thirdweb-dev/storage";
|
||||
import invariant from "tiny-invariant";
|
||||
|
||||
@@ -144,8 +148,10 @@ export class NFTCollection {
|
||||
* Get the all transactions for this program
|
||||
* @beta
|
||||
*/
|
||||
async getTransactions(): Promise<TransactionResponse[]> {
|
||||
return this.nft.getTransactions(this.publicKey.toBase58());
|
||||
async getTransactions(
|
||||
options?: SignaturesForAddressOptions,
|
||||
): Promise<TransactionResponse[]> {
|
||||
return this.nft.getTransactions(this.publicKey.toBase58(), options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,11 @@ import {
|
||||
toBigNumber,
|
||||
TransactionBuilder,
|
||||
} from "@metaplex-foundation/js";
|
||||
import { PublicKey, TransactionResponse } from "@solana/web3.js";
|
||||
import {
|
||||
PublicKey,
|
||||
SignaturesForAddressOptions,
|
||||
TransactionResponse,
|
||||
} from "@solana/web3.js";
|
||||
import { ThirdwebStorage, UploadProgressEvent } from "@thirdweb-dev/storage";
|
||||
import invariant from "tiny-invariant";
|
||||
|
||||
@@ -224,8 +228,10 @@ export class NFTDrop {
|
||||
* Get the all transactions for this program
|
||||
* @beta
|
||||
*/
|
||||
async getTransactions(): Promise<TransactionResponse[]> {
|
||||
return this.nft.getTransactions(this.publicKey.toBase58());
|
||||
async getTransactions(
|
||||
options?: SignaturesForAddressOptions,
|
||||
): Promise<TransactionResponse[]> {
|
||||
return this.nft.getTransactions(this.publicKey.toBase58(), options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.2.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`ec1f232`](https://github.com/thirdweb-dev/js/commit/ec1f2324c7a0e58c2d2a209cfe0d194807ba5b70), [`d29f7e7`](https://github.com/thirdweb-dev/js/commit/d29f7e78f09063630e812dd41164d8a41d4f97dd)]:
|
||||
- @thirdweb-dev/sdk@3.7.4
|
||||
|
||||
## 0.2.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Reference in New Issue
Block a user