Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

[Breaking change] Multichain SDK #477

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
624d1e6
Allow instantiating the SDK with just a chain name
joaquim-verges May 19, 2022
665429f
extract constant
joaquim-verges May 19, 2022
483967f
WIP refactor to separate signer and providers
joaquim-verges May 19, 2022
ef0c816
Merge branch 'main' into joaquim/separate_provider_and_signer
joaquim-verges Jun 17, 2022
1beebba
it compiles - testing time
joaquim-verges Jun 17, 2022
3ff22c8
tests passing
joaquim-verges Jun 17, 2022
e71816f
pass options to override RPC urls
joaquim-verges Jun 17, 2022
576883b
throw network mismatch error
joaquim-verges Jun 17, 2022
9414c58
expose nice error type
joaquim-verges Jun 17, 2022
07a0cee
Merge branch 'main' into joaquim/separate_provider_and_signer
joaquim-verges Jun 17, 2022
2b9c2b8
fix auth tests
joaquim-verges Jun 18, 2022
260419a
type wallet events + add disconnect handling in SDK
jnsdls Jun 18, 2022
7c38d69
import eventemitter from default export instead of named to resolve E…
jnsdls Jun 18, 2022
14e678f
enforce chainId everywhere, handle hardhat as special case
joaquim-verges Jun 19, 2022
b4d1846
fix fromPrivateKey
joaquim-verges Jun 19, 2022
f77319f
Merge branch 'main' into joaquim/separate_provider_and_signer
joaquim-verges Jun 25, 2022
19271c2
Merge branch 'main' into joaquim/separate_provider_and_signer
joaquim-verges Jun 26, 2022
b0a9338
Multichain SDK - override chain for any contract + getContract is now…
joaquim-verges Jun 27, 2022
33e1204
Merge branch 'main' into joaquim/separate_provider_and_signer
joaquim-verges Jun 27, 2022
c5cbdbb
fix eslint
joaquim-verges Jun 27, 2022
4e6186a
v3.0.0-0
joaquim-verges Jun 27, 2022
3f6fc20
expose get chain id
joaquim-verges Jun 28, 2022
2971183
forward chain param from getContract to getContractWithAbi
jnsdls Jun 28, 2022
83afd62
3.0.0-1 check in
jnsdls Jun 28, 2022
9e78ae9
v3.0.0-2
jnsdls Jun 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/feature_snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"summary": "Airdrop multiple NFTs\n\n",
"remarks": "\n\nAirdrop one or multiple NFTs to the provided wallet addresses.\n\n",
"examples": {
"javascript": "// The token ID of the NFT you want to airdrop\nconst tokenId = \"0\";\n// Array of objects of addresses and quantities to airdrop NFTs to\nconst addresses = [\n {\n address: \"0x...\",\n quantity: 2,\n },\n {\n address: \"0x...\",\n quantity: 3,\n },\n];\nawait contract.airdrop(tokenId, addresses);\n\n// You can also pass an array of addresses, it will airdrop 1 NFT per address\nconst tokenId = \"0\";\nconst addresses = [\n \"0x...\", \"0x...\", \"0x...\",\n]\nawait contract.airdrop(tokenId, addresses);"
"javascript": "// The token ID of the NFT you want to airdrop\nconst tokenId = \"0\";\n// Array of objects of addresses and quantities to airdrop NFTs to\nconst addresses = [\n {\n address: \"0x...\",\n quantity: 2,\n },\n {\n address: \"0x...\",\n quantity: 3,\n },\n];\nawait contract.airdrop(tokenId, addresses);\n\n// You can also pass an array of addresses, it will airdrop 1 NFT per address\nconst tokenId = \"0\";\nconst addresses = [\n \"0x...\", \"0x...\", \"0x...\",\n]\n\nawait contract.airdrop(tokenId, addresses);"
},
"reference": {
"javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155.airdrop"
Expand Down
14 changes: 14 additions & 0 deletions docs/sdk.chainandaddress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [ChainAndAddress](./sdk.chainandaddress.md)

## ChainAndAddress type

<b>Signature:</b>

```typescript
export declare type ChainAndAddress = {
chainId: ChainIdOrName;
address: string;
};
```
21 changes: 21 additions & 0 deletions docs/sdk.chainmismatcherror._constructor_.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [ChainMismatchError](./sdk.chainmismatcherror.md) &gt; [(constructor)](./sdk.chainmismatcherror._constructor_.md)

## ChainMismatchError.(constructor)

Constructs a new instance of the `ChainMismatchError` class

<b>Signature:</b>

```typescript
constructor(expectedChainId: ChainIdOrName, actualChainId: number);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| expectedChainId | ChainIdOrName | |
| actualChainId | number | |

21 changes: 21 additions & 0 deletions docs/sdk.chainmismatcherror.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [ChainMismatchError](./sdk.chainmismatcherror.md)

## ChainMismatchError class

Thrown when trying to do a transaction on a non-expected chain

<b>Signature:</b>

```typescript
export declare class ChainMismatchError extends Error
```
<b>Extends:</b> Error

## Constructors

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(expectedChainId, actualChainId)](./sdk.chainmismatcherror._constructor_.md) | | Constructs a new instance of the <code>ChainMismatchError</code> class |

15 changes: 15 additions & 0 deletions docs/sdk.connectioninfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [ConnectionInfo](./sdk.connectioninfo.md)

## ConnectionInfo type

<b>Signature:</b>

```typescript
export declare type ConnectionInfo = {
chainId: number;
signer: Signer | undefined;
provider?: providers.Provider;
};
```
4 changes: 2 additions & 2 deletions docs/sdk.contractdeployer._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Constructs a new instance of the `ContractDeployer` class
<b>Signature:</b>

```typescript
constructor(network: NetworkOrSignerOrProvider, options: SDKOptions, storage: IStorage);
constructor(connection: ConnectionInfo, options: SDKOptions, storage: IStorage);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| network | [NetworkOrSignerOrProvider](./sdk.networkorsignerorprovider.md) | |
| connection | [ConnectionInfo](./sdk.connectioninfo.md) | |
| options | [SDKOptions](./sdk.sdkoptions.md) | |
| storage | [IStorage](./sdk.istorage.md) | |

3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deployedition.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys a new Edition contract
<b>Signature:</b>

```typescript
deployEdition(metadata: NFTContractDeployMetadata): Promise<string>;
deployEdition(metadata: NFTContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [NFTContractDeployMetadata](./sdk.nftcontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deployeditiondrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys a new EditionDrop contract
<b>Signature:</b>

```typescript
deployEditionDrop(metadata: NFTContractDeployMetadata): Promise<string>;
deployEditionDrop(metadata: NFTContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [NFTContractDeployMetadata](./sdk.nftcontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deploymarketplace.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys a new Marketplace contract
<b>Signature:</b>

```typescript
deployMarketplace(metadata: MarketplaceContractDeployMetadata): Promise<string>;
deployMarketplace(metadata: MarketplaceContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [MarketplaceContractDeployMetadata](./sdk.marketplacecontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deploymultiwrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ Deploys a new Multiwrap contract
<b>Signature:</b>

```typescript
deployMultiwrap(metadata: MultiwrapContractDeployMetadata): Promise<string>;
deployMultiwrap(metadata: MultiwrapContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [MultiwrapContractDeployMetadata](./sdk.multiwrapcontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deploynftcollection.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys an NFT Collection contract
<b>Signature:</b>

```typescript
deployNFTCollection(metadata: NFTContractDeployMetadata): Promise<string>;
deployNFTCollection(metadata: NFTContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [NFTContractDeployMetadata](./sdk.nftcontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deploynftdrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys a new NFTDrop contract
<b>Signature:</b>

```typescript
deployNFTDrop(metadata: NFTContractDeployMetadata): Promise<string>;
deployNFTDrop(metadata: NFTContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [NFTContractDeployMetadata](./sdk.nftcontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deploypack.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys a new Pack contract
<b>Signature:</b>

```typescript
deployPack(metadata: NFTContractDeployMetadata): Promise<string>;
deployPack(metadata: NFTContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [NFTContractDeployMetadata](./sdk.nftcontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deploysplit.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys a new Split contract
<b>Signature:</b>

```typescript
deploySplit(metadata: SplitContractDeployMetadata): Promise<string>;
deploySplit(metadata: SplitContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [SplitContractDeployMetadata](./sdk.splitcontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deploytoken.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys a new Token contract
<b>Signature:</b>

```typescript
deployToken(metadata: TokenContractDeployMetadata): Promise<string>;
deployToken(metadata: TokenContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [TokenContractDeployMetadata](./sdk.tokencontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deploytokendrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys a new Token Drop contract
<b>Signature:</b>

```typescript
deployTokenDrop(metadata: TokenContractDeployMetadata): Promise<string>;
deployTokenDrop(metadata: TokenContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [TokenContractDeployMetadata](./sdk.tokencontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
3 changes: 2 additions & 1 deletion docs/sdk.contractdeployer.deployvote.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Deploys a new Vote contract
<b>Signature:</b>

```typescript
deployVote(metadata: VoteContractDeployMetadata): Promise<string>;
deployVote(metadata: VoteContractDeployMetadata, chain?: ChainIdOrName): Promise<string>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| metadata | [VoteContractDeployMetadata](./sdk.votecontractdeploymetadata.md) | the contract metadata |
| chain | ChainIdOrName | <i>(Optional)</i> the chain to deploy the contract to, defaults to the chain the SDK is connected to |

<b>Returns:</b>

Expand Down
26 changes: 13 additions & 13 deletions docs/sdk.contractdeployer.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ export declare class ContractDeployer extends RPCConnectionHandler

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(network, options, storage)](./sdk.contractdeployer._constructor_.md) | | Constructs a new instance of the <code>ContractDeployer</code> class |
| [(constructor)(connection, options, storage)](./sdk.contractdeployer._constructor_.md) | | Constructs a new instance of the <code>ContractDeployer</code> class |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [deployEdition(metadata)](./sdk.contractdeployer.deployedition.md) | | Deploys a new Edition contract |
| [deployEditionDrop(metadata)](./sdk.contractdeployer.deployeditiondrop.md) | | Deploys a new EditionDrop contract |
| [deployMarketplace(metadata)](./sdk.contractdeployer.deploymarketplace.md) | | Deploys a new Marketplace contract |
| [deployMultiwrap(metadata)](./sdk.contractdeployer.deploymultiwrap.md) | | <b><i>(BETA)</i></b> Deploys a new Multiwrap contract |
| [deployNFTCollection(metadata)](./sdk.contractdeployer.deploynftcollection.md) | | Deploys an NFT Collection contract |
| [deployNFTDrop(metadata)](./sdk.contractdeployer.deploynftdrop.md) | | Deploys a new NFTDrop contract |
| [deployPack(metadata)](./sdk.contractdeployer.deploypack.md) | | Deploys a new Pack contract |
| [deploySplit(metadata)](./sdk.contractdeployer.deploysplit.md) | | Deploys a new Split contract |
| [deployToken(metadata)](./sdk.contractdeployer.deploytoken.md) | | Deploys a new Token contract |
| [deployTokenDrop(metadata)](./sdk.contractdeployer.deploytokendrop.md) | | Deploys a new Token Drop contract |
| [deployVote(metadata)](./sdk.contractdeployer.deployvote.md) | | Deploys a new Vote contract |
| [updateSignerOrProvider(network)](./sdk.contractdeployer.updatesignerorprovider.md) | | |
| [deployEdition(metadata, chain)](./sdk.contractdeployer.deployedition.md) | | Deploys a new Edition contract |
| [deployEditionDrop(metadata, chain)](./sdk.contractdeployer.deployeditiondrop.md) | | Deploys a new EditionDrop contract |
| [deployMarketplace(metadata, chain)](./sdk.contractdeployer.deploymarketplace.md) | | Deploys a new Marketplace contract |
| [deployMultiwrap(metadata, chain)](./sdk.contractdeployer.deploymultiwrap.md) | | <b><i>(BETA)</i></b> Deploys a new Multiwrap contract |
| [deployNFTCollection(metadata, chain)](./sdk.contractdeployer.deploynftcollection.md) | | Deploys an NFT Collection contract |
| [deployNFTDrop(metadata, chain)](./sdk.contractdeployer.deploynftdrop.md) | | Deploys a new NFTDrop contract |
| [deployPack(metadata, chain)](./sdk.contractdeployer.deploypack.md) | | Deploys a new Pack contract |
| [deploySplit(metadata, chain)](./sdk.contractdeployer.deploysplit.md) | | Deploys a new Split contract |
| [deployToken(metadata, chain)](./sdk.contractdeployer.deploytoken.md) | | Deploys a new Token contract |
| [deployTokenDrop(metadata, chain)](./sdk.contractdeployer.deploytokendrop.md) | | Deploys a new Token Drop contract |
| [deployVote(metadata, chain)](./sdk.contractdeployer.deployvote.md) | | Deploys a new Vote contract |
| [updateSigner(signer)](./sdk.contractdeployer.updatesigner.md) | | |

22 changes: 22 additions & 0 deletions docs/sdk.contractdeployer.updatesigner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [ContractDeployer](./sdk.contractdeployer.md) &gt; [updateSigner](./sdk.contractdeployer.updatesigner.md)

## ContractDeployer.updateSigner() method

<b>Signature:</b>

```typescript
updateSigner(signer: Signer | undefined): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| signer | Signer \| undefined | |

<b>Returns:</b>

void

22 changes: 0 additions & 22 deletions docs/sdk.contractdeployer.updatesignerorprovider.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/sdk.edition._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Constructs a new instance of the `Edition` class
<b>Signature:</b>

```typescript
constructor(network: NetworkOrSignerOrProvider, address: string, storage: IStorage, options?: SDKOptions, contractWrapper?: ContractWrapper<TokenERC1155>);
constructor(connection: ConnectionInfo, address: string, storage: IStorage, options?: SDKOptions, contractWrapper?: ContractWrapper<TokenERC1155>);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| network | [NetworkOrSignerOrProvider](./sdk.networkorsignerorprovider.md) | |
| connection | [ConnectionInfo](./sdk.connectioninfo.md) | |
| address | string | |
| storage | [IStorage](./sdk.istorage.md) | |
| options | [SDKOptions](./sdk.sdkoptions.md) | <i>(Optional)</i> |
Expand Down
2 changes: 1 addition & 1 deletion docs/sdk.edition.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const contract = sdk.getEdition("{{contract_address}}");

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(network, address, storage, options, contractWrapper)](./sdk.edition._constructor_.md) | | Constructs a new instance of the <code>Edition</code> class |
| [(constructor)(connection, address, storage, options, contractWrapper)](./sdk.edition._constructor_.md) | | Constructs a new instance of the <code>Edition</code> class |

## Properties

Expand Down
Loading