Skip to content

Commit

Permalink
Merge branch 'main' into greg/react-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gregfromstl committed May 17, 2024
2 parents 677c30f + d874365 commit 8898a67
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 59 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-cobras-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

ethers6 adapter: allow optional account to be passed to `contract.toEthers` that will automatically hook up the contract with a signer instead of provider
5 changes: 5 additions & 0 deletions .changeset/stupid-snails-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/unity-js-bridge": patch
---

Unity 4.13.2
5 changes: 5 additions & 0 deletions .changeset/sync-chains.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/chains": patch
---

Synced Chains Package
30 changes: 30 additions & 0 deletions legacy_packages/chains/chains/10849.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Chain } from "../src/types";
export default {
"chain": "Avalanche",
"chainId": 10849,
"explorers": [],
"faucets": [],
"features": [],
"icon": {
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
"width": 256,
"height": 256,
"format": "svg"
},
"infoURL": "https://avacloud.io",
"name": "Lamina1",
"nativeCurrency": {
"name": "Lamina1 Token",
"symbol": "L",
"decimals": 18
},
"networkId": 10849,
"redFlags": [],
"rpc": [
"https://10849.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://subnets.avax.network/lamina1/mainnet/rpc"
],
"shortName": "Lamina1",
"slug": "lamina1",
"testnet": false
} as const satisfies Chain;
30 changes: 30 additions & 0 deletions legacy_packages/chains/chains/10850.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Chain } from "../src/types";
export default {
"chain": "Avalanche",
"chainId": 10850,
"explorers": [],
"faucets": [],
"features": [],
"icon": {
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
"width": 256,
"height": 256,
"format": "svg"
},
"infoURL": "https://avacloud.io",
"name": "Lamina1 Identity",
"nativeCurrency": {
"name": "Lamina1 Identity Token",
"symbol": "LID",
"decimals": 18
},
"networkId": 10850,
"redFlags": [],
"rpc": [
"https://10850.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://subnets.avax.network/lamina1id/mainnet/rpc"
],
"shortName": "Lamina1 Identity",
"slug": "lamina1-identity",
"testnet": false
} as const satisfies Chain;
6 changes: 0 additions & 6 deletions legacy_packages/chains/chains/1319.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ export default {
}
],
"faucets": [],
"icon": {
"url": "ipfs://QmXbBMMhjTTGAGjmqMpJm3ufFrtdkfEXCFyXYgz7nnZzsy",
"width": 160,
"height": 160,
"format": "png"
},
"infoURL": "https://aiachain.org/",
"name": "AIA Mainnet",
"nativeCurrency": {
Expand Down
6 changes: 0 additions & 6 deletions legacy_packages/chains/chains/1320.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ export default {
"name": "EIP1559"
}
],
"icon": {
"url": "ipfs://QmXbBMMhjTTGAGjmqMpJm3ufFrtdkfEXCFyXYgz7nnZzsy",
"width": 160,
"height": 160,
"format": "png"
},
"infoURL": "https://aiachain.org",
"name": "AIA Testnet",
"nativeCurrency": {
Expand Down
6 changes: 0 additions & 6 deletions legacy_packages/chains/chains/1482601649.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ export default {
"faucets": [
"https://sfuel.skale.network/"
],
"icon": {
"url": "ipfs://bafybeic5eexvd34wfy4kuebcyu73qpkv3x57s54ebzjyhyjsmeuni5jwcm",
"width": 500,
"height": 500,
"format": "png"
},
"infoURL": "https://nebulachain.io/",
"name": "SKALE Nebula Hub",
"nativeCurrency": {
Expand Down
30 changes: 30 additions & 0 deletions legacy_packages/chains/chains/21825.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Chain } from "../src/types";
export default {
"chain": "Avalanche",
"chainId": 21825,
"explorers": [],
"faucets": [],
"features": [],
"icon": {
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
"width": 256,
"height": 256,
"format": "svg"
},
"infoURL": "https://avacloud.io",
"name": "QaUser6991",
"nativeCurrency": {
"name": "QaUser6991 Token",
"symbol": "HIO",
"decimals": 18
},
"networkId": 21825,
"redFlags": [],
"rpc": [
"https://21825.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
],
"shortName": "QaUser6991",
"slug": "qauser6991",
"testnet": true
} as const satisfies Chain;
6 changes: 0 additions & 6 deletions legacy_packages/chains/chains/37084624.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ export default {
"faucets": [
"https://www.sfuelstation.com/"
],
"icon": {
"url": "ipfs://bafybeic5eexvd34wfy4kuebcyu73qpkv3x57s54ebzjyhyjsmeuni5jwcm",
"width": 500,
"height": 500,
"format": "png"
},
"infoURL": "https://nebulachain.io/",
"name": "SKALE Nebula Hub Testnet",
"nativeCurrency": {
Expand Down
6 changes: 0 additions & 6 deletions legacy_packages/chains/chains/503129905.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ export default {
"faucets": [
"https://sfuel.dirtroad.dev/staging"
],
"icon": {
"url": "ipfs://bafybeic5eexvd34wfy4kuebcyu73qpkv3x57s54ebzjyhyjsmeuni5jwcm",
"width": 500,
"height": 500,
"format": "png"
},
"infoURL": "https://nebulachain.io/",
"name": "Deprecated SKALE Nebula Hub Testnet",
"nativeCurrency": {
Expand Down
14 changes: 1 addition & 13 deletions legacy_packages/chains/chains/73927.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,10 @@ export default {
{
"name": "mvmscan",
"url": "https://scan.mvm.dev",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmeuDgSprukzfV7fi9XYHYcfmT4aZZZU7idgShtRS8Vf6V",
"width": 471,
"height": 512,
"format": "png"
}
"standard": "EIP3091"
}
],
"faucets": [],
"icon": {
"url": "ipfs://QmeuDgSprukzfV7fi9XYHYcfmT4aZZZU7idgShtRS8Vf6V",
"width": 471,
"height": 512,
"format": "png"
},
"infoURL": "https://mvm.dev",
"name": "Mixin Virtual Machine",
"nativeCurrency": {
Expand Down
6 changes: 0 additions & 6 deletions legacy_packages/chains/chains/761412.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ export default {
}
],
"faucets": [],
"icon": {
"url": "ipfs://bafkreic6tcc6swh5kzljwqnswj6rlemcm7n6ra7xkgttwv5v3fv7ozj5zu",
"width": 1500,
"height": 1500,
"format": "png"
},
"infoURL": "https://miexs.com",
"name": "Miexs Smartchain",
"nativeCurrency": {
Expand Down
30 changes: 30 additions & 0 deletions legacy_packages/chains/chains/77898.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Chain } from "../src/types";
export default {
"chain": "Avalanche",
"chainId": 77898,
"explorers": [],
"faucets": [],
"features": [],
"icon": {
"url": "https://images.ctfassets.net/9bazykntljf6/62CceHSYsRS4D9fgDSkLRB/877cb8f26954e1743ff535fd7fdaf78f/avacloud-placeholder.svg",
"width": 256,
"height": 256,
"format": "svg"
},
"infoURL": "https://avacloud.io",
"name": "QI0517I1",
"nativeCurrency": {
"name": "QI0517I1 Token",
"symbol": "YGV",
"decimals": 18
},
"networkId": 77898,
"redFlags": [],
"rpc": [
"https://77898.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"
],
"shortName": "QI0517I1",
"slug": "qi0517i1",
"testnet": true
} as const satisfies Chain;
18 changes: 17 additions & 1 deletion legacy_packages/chains/src/index.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion legacy_packages/unity-js-bridge/src/thirdweb-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class ThirdwebBridge implements TWBridge {
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
(globalThis as any).X_SDK_PLATFORM = "unity";
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
(globalThis as any).X_SDK_VERSION = "4.13.1";
(globalThis as any).X_SDK_VERSION = "4.13.2";
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix use of any
(globalThis as any).X_SDK_OS = browser?.os ?? "unknown";
}
Expand Down
28 changes: 20 additions & 8 deletions packages/thirdweb/src/adapters/ethers6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const ethers6Adapter = /* @__PURE__ */ (() => {
* @example
* ```ts
* import { ethers6Adapter } from "thirdweb/adapters/ethers6";
* const provider = ethers6Adapter.provider.toEthers({ client, chainId });
* const provider = ethers6Adapter.provider.toEthers({ client, chain });
* ```
*/
toEthers: (options: { client: ThirdwebClient; chain: Chain }) => {
Expand All @@ -79,9 +79,16 @@ export const ethers6Adapter = /* @__PURE__ */ (() => {
* const ethersContract = await ethers6Adapter.contract.toEthers({ thirdwebContract });
* ```
*/
toEthers: (options: { thirdwebContract: ThirdwebContract }) => {
toEthers: (options: {
thirdwebContract: ThirdwebContract;
account?: Account;
}) => {
assertEthers6(ethers);
return toEthersContract(ethers, options.thirdwebContract);
return toEthersContract(
ethers,
options.thirdwebContract,
options.account,
);
},
/**
* Creates a ThirdwebContract instance from an ethers.js contract.
Expand Down Expand Up @@ -186,12 +193,15 @@ function toEthersProvider(
async function toEthersContract<abi extends Abi = []>(
ethers: Ethers6,
twContract: ThirdwebContract<abi>,
account?: Account,
): Promise<ethers6.Contract> {
if (twContract.abi) {
return new ethers.Contract(
twContract.address,
JSON.stringify(twContract.abi),
toEthersProvider(ethers, twContract.client, twContract.chain),
account
? toEthersSigner(ethers, twContract.client, account, twContract.chain)
: toEthersProvider(ethers, twContract.client, twContract.chain),
);
}

Expand All @@ -204,7 +214,9 @@ async function toEthersContract<abi extends Abi = []>(
return new ethers.Contract(
twContract.address,
JSON.stringify(abi),
toEthersProvider(ethers, twContract.client, twContract.chain),
account
? toEthersSigner(ethers, twContract.client, account, twContract.chain)
: toEthersProvider(ethers, twContract.client, twContract.chain),
);
}

Expand Down Expand Up @@ -278,15 +290,15 @@ async function fromEthersSigner(signer: ethers6.Signer): Promise<Account> {
* @param client - The Thirdweb client.
* @param chain - The blockchain chain.
* @param account - The Thirdweb account.
* @returns A promise that resolves to an ethers.js signer.
* @returns An ethers.js signer.
* @internal
*/
export async function toEthersSigner(
export function toEthersSigner(
ethers: Ethers6,
client: ThirdwebClient,
account: Account,
chain: Chain,
): Promise<ethers6.Signer> {
): ethers6.Signer {
class ThirdwebAdapterSigner extends ethers.AbstractSigner<ethers6.JsonRpcProvider> {
private address: string;
override provider: ethers6.ethers.JsonRpcProvider;
Expand Down

0 comments on commit 8898a67

Please sign in to comment.