Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cb580e99e | ||
|
|
eff710738c | ||
|
|
fb6a07d4b8 | ||
|
|
7768067bf4 |
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/auth
|
||||
|
||||
## 4.1.93
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies []:
|
||||
- @thirdweb-dev/wallets@2.5.35
|
||||
|
||||
## 4.1.92
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/auth",
|
||||
"version": "4.1.92",
|
||||
"version": "4.1.93",
|
||||
"main": "dist/thirdweb-dev-auth.cjs.js",
|
||||
"module": "dist/thirdweb-dev-auth.esm.js",
|
||||
"browser": {
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# thirdweb
|
||||
|
||||
## 0.14.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`7768067`](https://github.com/thirdweb-dev/js/commit/7768067bf4f571a8c8ee6b646a58e2fc5f6bd052)]:
|
||||
- @thirdweb-dev/sdk@4.0.95
|
||||
- @thirdweb-dev/wallets@2.5.35
|
||||
- @thirdweb-dev/auth@4.1.93
|
||||
|
||||
## 0.14.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/cli",
|
||||
"main": "dist/cli/index.js",
|
||||
"version": "0.14.7",
|
||||
"version": "0.14.8",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/cli",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# @thirdweb-dev/react-core
|
||||
|
||||
## 4.9.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`7768067`](https://github.com/thirdweb-dev/js/commit/7768067bf4f571a8c8ee6b646a58e2fc5f6bd052)]:
|
||||
- @thirdweb-dev/sdk@4.0.95
|
||||
- @thirdweb-dev/wallets@2.5.35
|
||||
- @thirdweb-dev/auth@4.1.93
|
||||
|
||||
## 4.8.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react-core",
|
||||
"version": "4.8.0",
|
||||
"version": "4.9.0",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react-core",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,18 @@
|
||||
# @thirdweb-dev/react
|
||||
|
||||
## 4.9.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#3315](https://github.com/thirdweb-dev/js/pull/3315) [`eff7107`](https://github.com/thirdweb-dev/js/commit/eff710738ce3d4341257e5912311c95b28a34b5d) Thanks [@MananTank](https://github.com/MananTank)! - Allow configuring WalletConnect `qrcode` and `qrModalOptions` from wallet configurator functions like `metamaskWallet`, `coreWallet`, `zerionWallet` etc
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`7768067`](https://github.com/thirdweb-dev/js/commit/7768067bf4f571a8c8ee6b646a58e2fc5f6bd052)]:
|
||||
- @thirdweb-dev/sdk@4.0.95
|
||||
- @thirdweb-dev/react-core@4.9.0
|
||||
- @thirdweb-dev/wallets@2.5.35
|
||||
|
||||
## 4.8.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/react",
|
||||
"version": "4.8.0",
|
||||
"version": "4.9.0",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/react",
|
||||
"author": "thirdweb eng <[email protected]>",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -6,6 +6,7 @@ import type {
|
||||
import { Coin98Wallet, getInjectedCoin98Provider } from "@thirdweb-dev/wallets";
|
||||
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
const coin98WalletUris = {
|
||||
ios: "coin98://",
|
||||
@@ -29,6 +30,22 @@ export type Coin98WalletConfigOptions = {
|
||||
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
|
||||
*/
|
||||
recommended?: boolean;
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -78,7 +95,11 @@ export const coin98Wallet = (
|
||||
const wallet = new Coin98Wallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
return wallet;
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
import { handelWCSessionRequest } from "../handleWCSessionRequest";
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
const coreWalletUris = {
|
||||
ios: "core://",
|
||||
@@ -33,6 +34,22 @@ export type CoreWalletConfigOptions = {
|
||||
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
|
||||
*/
|
||||
recommended?: boolean;
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -81,7 +98,11 @@ export const coreWallet = (
|
||||
const wallet = new CoreWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
handelWCSessionRequest(wallet, coreWalletUris);
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
|
||||
import { handelWCSessionRequest } from "../handleWCSessionRequest";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
const cryptoDefiWalletUris = {
|
||||
ios: "dfw://",
|
||||
@@ -33,6 +34,22 @@ export type CryptoDefiWalletConfigOptions = {
|
||||
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
|
||||
*/
|
||||
recommended?: boolean;
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -82,7 +99,11 @@ export const cryptoDefiWallet = (
|
||||
const wallet = new CryptoDefiWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
handelWCSessionRequest(wallet, cryptoDefiWalletUris);
|
||||
|
||||
@@ -6,6 +6,7 @@ import type {
|
||||
import { ImTokenWallet, assertWindowEthereum } from "@thirdweb-dev/wallets";
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
const imTokenWalletUris = {
|
||||
ios: "imtokenv2://",
|
||||
@@ -15,6 +16,22 @@ const imTokenWalletUris = {
|
||||
export type ImTokenWalletConfigOptions = {
|
||||
projectId?: string;
|
||||
recommended?: boolean;
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
export const imTokenWallet = (
|
||||
@@ -30,7 +47,11 @@ export const imTokenWallet = (
|
||||
const wallet = new ImTokenWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
return wallet;
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
import { MetamaskConnectUI } from "./MetamaskConnectUI";
|
||||
import { metamaskUris } from "./metamaskUris";
|
||||
import { handelWCSessionRequest } from "../handleWCSessionRequest";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
/**
|
||||
* @wallet
|
||||
@@ -35,6 +36,22 @@ export type MetamaskWalletConfigOptions = {
|
||||
* Default is `"walletconnect"`
|
||||
*/
|
||||
connectionMethod?: "walletConnect" | "metamaskBrowser";
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -89,7 +106,11 @@ export const metamaskWallet = (
|
||||
const wallet = new MetaMaskWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
if (connectionMethod === "walletConnect") {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
|
||||
import { OKXWallet, getInjectedOKXProvider } from "@thirdweb-dev/wallets";
|
||||
import { OKXConnectUI } from "./OKXConnectUI";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
/**
|
||||
* @wallet
|
||||
@@ -18,6 +19,22 @@ export type OKXWalletConfigOptions = {
|
||||
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
|
||||
*/
|
||||
recommended?: boolean;
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,7 +84,11 @@ export const okxWallet = (
|
||||
const wallet = new OKXWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
return wallet;
|
||||
|
||||
@@ -6,6 +6,7 @@ import type {
|
||||
import { OneKeyWallet, getInjectedOneKeyProvider } from "@thirdweb-dev/wallets";
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
export const oneKeyWalletUris = {
|
||||
ios: "onekey-wallet://",
|
||||
@@ -29,6 +30,22 @@ export type OneKeyWalletConfigOptions = {
|
||||
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
|
||||
*/
|
||||
recommended?: boolean;
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -78,7 +95,11 @@ export const oneKeyWallet = (
|
||||
const wallet = new OneKeyWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
return wallet;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
|
||||
import { RabbyWallet, getInjectedRabbyProvider } from "@thirdweb-dev/wallets";
|
||||
import { RabbyConnectUI } from "./RabbyConnectUI";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
/**
|
||||
* @wallet
|
||||
@@ -18,6 +19,22 @@ export type RabbyWalletConfigOptions = {
|
||||
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
|
||||
*/
|
||||
recommended?: boolean;
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -64,7 +81,11 @@ export const rabbyWallet = (
|
||||
const wallet = new RabbyWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
return wallet;
|
||||
|
||||
@@ -7,6 +7,7 @@ import { TrustWallet, assertWindowEthereum } from "@thirdweb-dev/wallets";
|
||||
import { handelWCSessionRequest } from "../handleWCSessionRequest";
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
const trustWalletUris = {
|
||||
ios: "trust://",
|
||||
@@ -30,6 +31,22 @@ export type TrustWalletConfigOptions = {
|
||||
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
|
||||
*/
|
||||
recommended?: boolean;
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -72,7 +89,11 @@ export const trustWallet = (
|
||||
const wallet = new TrustWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
handelWCSessionRequest(wallet, trustWalletUris);
|
||||
|
||||
@@ -7,6 +7,7 @@ import { ZerionWallet, assertWindowEthereum } from "@thirdweb-dev/wallets";
|
||||
import { handelWCSessionRequest } from "../handleWCSessionRequest";
|
||||
import { useTWLocale } from "../../../evm/providers/locale-provider";
|
||||
import { ExtensionOrWCConnectionUI } from "../_common/ExtensionORWCConnectionUI";
|
||||
import type { QRModalOptions } from "@thirdweb-dev/wallets/src/evm/connectors/wallet-connect/qrModalOptions";
|
||||
|
||||
const zerionWalletUris = {
|
||||
ios: "zerion://",
|
||||
@@ -30,6 +31,22 @@ export type ZerionkWalletConfigOptions = {
|
||||
* If true, the wallet will be tagged as "recommended" in ConnectWallet Modal
|
||||
*/
|
||||
recommended?: boolean;
|
||||
|
||||
/**
|
||||
* Specify whether to open the official Wallet Connect Modal when connecting the wallet if no injected MetaMask provider is found when connecting the wallet.
|
||||
*
|
||||
* This should not be set if you are using ConnectWallet component and only when manually connecting the wallet using a hook like `useConnect`.
|
||||
*
|
||||
* You can set it to `true` or a configuration object to enable the Wallet Connect Modal.
|
||||
*/
|
||||
wcModal?:
|
||||
| {
|
||||
/**
|
||||
* Configure the style of Wallet Connect Modal.
|
||||
*/
|
||||
qrModalOptions?: QRModalOptions;
|
||||
}
|
||||
| boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -72,7 +89,11 @@ export const zerionWallet = (
|
||||
const wallet = new ZerionWallet({
|
||||
...walletOptions,
|
||||
projectId: options?.projectId,
|
||||
qrcode: false,
|
||||
qrcode: options?.wcModal ? true : false,
|
||||
qrModalOptions:
|
||||
typeof options?.wcModal === "object"
|
||||
? options?.wcModal?.qrModalOptions
|
||||
: undefined,
|
||||
});
|
||||
|
||||
handelWCSessionRequest(wallet, zerionWalletUris);
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,14 @@
|
||||
# @thirdweb-dev/sdk
|
||||
|
||||
## 4.0.95
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2880](https://github.com/thirdweb-dev/js/pull/2880) [`7768067`](https://github.com/thirdweb-dev/js/commit/7768067bf4f571a8c8ee6b646a58e2fc5f6bd052) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Modular contract publish and deploy setup
|
||||
|
||||
- Updated dependencies [[`7768067`](https://github.com/thirdweb-dev/js/commit/7768067bf4f571a8c8ee6b646a58e2fc5f6bd052), [`fb6a07d`](https://github.com/thirdweb-dev/js/commit/fb6a07d4b84ba8ea6389ca04c73625f670a0d9c4)]:
|
||||
- thirdweb@5.29.2
|
||||
|
||||
## 4.0.94
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/sdk",
|
||||
"version": "4.0.94",
|
||||
"version": "4.0.95",
|
||||
"description": "The main thirdweb SDK.",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/legacy_packages/sdk",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
import { providers, utils } from "ethers";
|
||||
import {
|
||||
coreContractAbi,
|
||||
extensionContractAbi,
|
||||
} from "../../constants/thirdweb-features";
|
||||
import { hasDuplicates } from "../utils";
|
||||
import { getChainByChainIdAsync, getChainRPC } from "@thirdweb-dev/chains";
|
||||
|
||||
type CallbackFunction = {
|
||||
selector: string;
|
||||
};
|
||||
|
||||
type FallbackFunction = {
|
||||
selector: string;
|
||||
permissionBits: string;
|
||||
};
|
||||
|
||||
type SupportedCallbackFunction = {
|
||||
selector: string;
|
||||
mode: number;
|
||||
};
|
||||
|
||||
export async function compatibleExtensions(
|
||||
coreBytecode: string,
|
||||
extensionBytecodes: string[],
|
||||
chainId: number,
|
||||
): Promise<boolean> {
|
||||
const chain = await getChainByChainIdAsync(chainId);
|
||||
const rpcUrl = getChainRPC(chain);
|
||||
const jsonRpcProvider = new providers.JsonRpcProvider(rpcUrl);
|
||||
const addr = "0x0000000000000000000000000000000000000124"; // arbitrary address
|
||||
|
||||
/**
|
||||
* Here we use state override with eth_call.
|
||||
*
|
||||
* This lets us call functions on a non-deployed contract, by using its deployed bytecode
|
||||
* to override code of an arbitrary address in eth_call.
|
||||
*
|
||||
* Encode function calldata, and perform eth_call with bytecode override.
|
||||
*/
|
||||
|
||||
const coreIface = new utils.Interface(coreContractAbi);
|
||||
const coreCalldata = coreIface.encodeFunctionData(
|
||||
"getSupportedCallbackFunctions",
|
||||
[],
|
||||
);
|
||||
if (!coreBytecode.startsWith("0x6080604052")) {
|
||||
const index = coreBytecode.indexOf("6080604052");
|
||||
coreBytecode = `0x${coreBytecode.substring(index)}`;
|
||||
} else if (coreBytecode.lastIndexOf("6080604052") > 0) {
|
||||
const index = coreBytecode.lastIndexOf("6080604052");
|
||||
coreBytecode = `0x${coreBytecode.substring(index)}`;
|
||||
}
|
||||
const core = await jsonRpcProvider.send("eth_call", [
|
||||
{ to: addr, data: coreCalldata },
|
||||
"latest",
|
||||
{ [addr]: { code: coreBytecode } }, // eth_call with bytecode override
|
||||
]);
|
||||
|
||||
const extensionIface = new utils.Interface(extensionContractAbi);
|
||||
const extensionCalldata = extensionIface.encodeFunctionData(
|
||||
"getExtensionConfig",
|
||||
[],
|
||||
);
|
||||
const extensions = await Promise.all(
|
||||
extensionBytecodes.map((b: string) => {
|
||||
// TODO: Upload deployed bytecode on publish metadata
|
||||
|
||||
if (!b.startsWith("0x6080604052")) {
|
||||
const index = b.indexOf("6080604052");
|
||||
b = `0x${b.substring(index)}`;
|
||||
} else if (b.lastIndexOf("6080604052") > 0) {
|
||||
const index = b.lastIndexOf("6080604052");
|
||||
b = `0x${b.substring(index)}`;
|
||||
}
|
||||
|
||||
return jsonRpcProvider.send("eth_call", [
|
||||
{ to: addr, data: extensionCalldata },
|
||||
"latest",
|
||||
{ [addr]: { code: b } }, // eth_call with bytecode override
|
||||
]);
|
||||
}),
|
||||
);
|
||||
|
||||
const decodedCore = coreIface.decodeFunctionResult(
|
||||
"getSupportedCallbackFunctions",
|
||||
core,
|
||||
);
|
||||
const coreCallbackSelectors = decodedCore.flat().map(
|
||||
(c: SupportedCallbackFunction) => c.selector,
|
||||
);
|
||||
|
||||
// extract callback/fallback selectors and required interfaces from extension config
|
||||
const requiredInterfaces: string[] = [];
|
||||
const extensionFallbackSelectors: string[] = [];
|
||||
const extensionCallbackSelectors: string[] = [];
|
||||
const selectors: string[] = [];
|
||||
|
||||
extensions.forEach((e: string) => {
|
||||
const decodedExtensionConfig = extensionIface.decodeFunctionResult(
|
||||
"getExtensionConfig",
|
||||
e,
|
||||
);
|
||||
|
||||
requiredInterfaces.push(...decodedExtensionConfig[0].requiredInterfaces);
|
||||
const fallbackSelectors =
|
||||
decodedExtensionConfig[0].fallbackFunctions.map(
|
||||
(a: FallbackFunction) => a.selector,
|
||||
);
|
||||
const callbackSelectors =
|
||||
decodedExtensionConfig[0].callbackFunctions.map(
|
||||
(a: CallbackFunction) => a.selector,
|
||||
);
|
||||
|
||||
extensionFallbackSelectors.push(...fallbackSelectors);
|
||||
extensionCallbackSelectors.push(...callbackSelectors);
|
||||
});
|
||||
|
||||
// check if callback selectors are supported
|
||||
for(const callback of extensionCallbackSelectors) {
|
||||
if(!coreCallbackSelectors.includes(callback)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the core contract supports required interfaces by extensions above
|
||||
if(requiredInterfaces.length > 0) {
|
||||
const supportsInterfaceResult = await Promise.all(
|
||||
requiredInterfaces.map((r) => {
|
||||
const supportsInterfaceCalldata = coreIface.encodeFunctionData(
|
||||
"supportsInterface",
|
||||
[r],
|
||||
);
|
||||
return jsonRpcProvider.send("eth_call", [
|
||||
{ to: addr, data: supportsInterfaceCalldata },
|
||||
"latest",
|
||||
{ [addr]: { code: coreBytecode } },
|
||||
]);
|
||||
}),
|
||||
);
|
||||
const supportsInterfaceDecoded = supportsInterfaceResult.map(r => {
|
||||
return coreIface.decodeFunctionResult(
|
||||
"supportsInterface",
|
||||
r,
|
||||
);
|
||||
})
|
||||
if (supportsInterfaceDecoded.flat().some((element) => element === false)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check duplicate callback/fallback signatures
|
||||
selectors.push(...extensionFallbackSelectors, ...extensionCallbackSelectors);
|
||||
return !hasDuplicates(
|
||||
selectors.flat(),
|
||||
(a: string, b: string): boolean => a === b,
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
coreContractAbi,
|
||||
getAllExtensionsAbi,
|
||||
getAllPluginsAbi,
|
||||
} from "../../constants/thirdweb-features";
|
||||
@@ -38,6 +39,7 @@ export async function getCompositeABI(
|
||||
"DynamicContract",
|
||||
features,
|
||||
);
|
||||
const isModular: boolean = isExtensionEnabled(abi, "ModularCore", features);
|
||||
// check if the contract has fallback function - we'll further check for diamond pattern if needed
|
||||
const isFallback: boolean = isExtensionEnabled(abi, "Fallback", features);
|
||||
|
||||
@@ -59,6 +61,24 @@ export async function getCompositeABI(
|
||||
|
||||
// get ABIs of extension contracts --
|
||||
pluginABIs = await getPluginABI(pluginAddresses, provider, storage);
|
||||
} else if (isModular) {
|
||||
const contract = new ContractWrapper(
|
||||
provider,
|
||||
address,
|
||||
coreContractAbi,
|
||||
options,
|
||||
storage,
|
||||
);
|
||||
|
||||
const extensions = await contract.call("getInstalledExtensions");
|
||||
|
||||
// get extension addresses
|
||||
const extensionAddresses = extensions.map(
|
||||
(item: any) => item.implementation,
|
||||
);
|
||||
|
||||
// get ABIs of extension contracts --
|
||||
pluginABIs = await getPluginABI(extensionAddresses, provider, storage);
|
||||
} else if (isPluginRouter) {
|
||||
const contract = new ContractWrapper(
|
||||
provider,
|
||||
|
||||
@@ -30,6 +30,27 @@ export function unique<T>(a: T[], fn: (a: T, b: T) => boolean): T[] {
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function hasDuplicates<T>(arr: T[], fn: (a: T, b: T) => boolean): boolean {
|
||||
if (arr.length === 0 || arr.length === 1) {
|
||||
return false;
|
||||
}
|
||||
if (!fn) {
|
||||
throw new Error("Comparison function required");
|
||||
}
|
||||
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
for (let j = i + 1; j < arr.length; j++) {
|
||||
if (fn(arr[i], arr[j])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
||||
@@ -63,6 +63,8 @@ import {
|
||||
FEATURE_GASLESS,
|
||||
FEATURE_PACK_VRF,
|
||||
FEATURE_PLUGIN_ROUTER,
|
||||
FEATURE_MODULAR_CORE,
|
||||
FEATURE_MODULAR_EXTENSION,
|
||||
FEATURE_DIRECT_LISTINGS,
|
||||
FEATURE_ENGLISH_AUCTIONS,
|
||||
FEATURE_OFFERS,
|
||||
@@ -139,6 +141,8 @@ export type Feature =
|
||||
| typeof FEATURE_GASLESS
|
||||
| typeof FEATURE_PACK_VRF
|
||||
| typeof FEATURE_PLUGIN_ROUTER
|
||||
| typeof FEATURE_MODULAR_CORE
|
||||
| typeof FEATURE_MODULAR_EXTENSION
|
||||
| typeof FEATURE_DYNAMIC_CONTRACT
|
||||
| typeof FEATURE_DIRECT_LISTINGS
|
||||
| typeof FEATURE_ENGLISH_AUCTIONS
|
||||
@@ -189,6 +193,8 @@ export const SUPPORTED_FEATURES: Record<string, Feature> = /* @__PURE__ */ {
|
||||
[FEATURE_PACK_VRF.name]: FEATURE_PACK_VRF,
|
||||
[FEATURE_PLUGIN_ROUTER.name]: FEATURE_PLUGIN_ROUTER,
|
||||
[FEATURE_DYNAMIC_CONTRACT.name]: FEATURE_DYNAMIC_CONTRACT,
|
||||
[FEATURE_MODULAR_CORE.name]: FEATURE_MODULAR_CORE,
|
||||
[FEATURE_MODULAR_EXTENSION.name]: FEATURE_MODULAR_EXTENSION,
|
||||
[FEATURE_DIRECT_LISTINGS.name]: FEATURE_DIRECT_LISTINGS,
|
||||
[FEATURE_ENGLISH_AUCTIONS.name]: FEATURE_ENGLISH_AUCTIONS,
|
||||
[FEATURE_OFFERS.name]: FEATURE_OFFERS,
|
||||
|
||||
@@ -116,6 +116,450 @@ export const getAllExtensionsAbi = [
|
||||
},
|
||||
];
|
||||
|
||||
export const coreContractAbi = [
|
||||
{ type: "fallback", stateMutability: "payable" },
|
||||
{
|
||||
type: "function",
|
||||
name: "cancelOwnershipHandover",
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "completeOwnershipHandover",
|
||||
inputs: [
|
||||
{ name: "pendingOwner", type: "address", internalType: "address" },
|
||||
],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "getInstalledExtensions",
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
name: "_installedExtensions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IModularCore.InstalledExtension[]",
|
||||
components: [
|
||||
{
|
||||
name: "implementation",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "config",
|
||||
type: "tuple",
|
||||
internalType: "struct IExtensionConfig.ExtensionConfig",
|
||||
components: [
|
||||
{
|
||||
name: "registerInstallationCallback",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
{
|
||||
name: "requiredInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "supportedInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "callbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.CallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "fallbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.FallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
{
|
||||
name: "permissionBits",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "getSupportedCallbackFunctions",
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
name: "",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IModularCore.SupportedCallbackFunction[]",
|
||||
components: [
|
||||
{ name: "selector", type: "bytes4", internalType: "bytes4" },
|
||||
{
|
||||
name: "mode",
|
||||
type: "uint8",
|
||||
internalType: "enum IModularCore.CallbackMode",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
stateMutability: "pure",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "grantRoles",
|
||||
inputs: [
|
||||
{ name: "user", type: "address", internalType: "address" },
|
||||
{ name: "roles", type: "uint256", internalType: "uint256" },
|
||||
],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "hasAllRoles",
|
||||
inputs: [
|
||||
{ name: "user", type: "address", internalType: "address" },
|
||||
{ name: "roles", type: "uint256", internalType: "uint256" },
|
||||
],
|
||||
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
||||
stateMutability: "view",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "hasAnyRole",
|
||||
inputs: [
|
||||
{ name: "user", type: "address", internalType: "address" },
|
||||
{ name: "roles", type: "uint256", internalType: "uint256" },
|
||||
],
|
||||
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
||||
stateMutability: "view",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "installExtension",
|
||||
inputs: [
|
||||
{ name: "_extension", type: "address", internalType: "address" },
|
||||
{ name: "_data", type: "bytes", internalType: "bytes" },
|
||||
],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "owner",
|
||||
inputs: [],
|
||||
outputs: [{ name: "result", type: "address", internalType: "address" }],
|
||||
stateMutability: "view",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "ownershipHandoverExpiresAt",
|
||||
inputs: [
|
||||
{ name: "pendingOwner", type: "address", internalType: "address" },
|
||||
],
|
||||
outputs: [{ name: "result", type: "uint256", internalType: "uint256" }],
|
||||
stateMutability: "view",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "renounceOwnership",
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "renounceRoles",
|
||||
inputs: [{ name: "roles", type: "uint256", internalType: "uint256" }],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "requestOwnershipHandover",
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "revokeRoles",
|
||||
inputs: [
|
||||
{ name: "user", type: "address", internalType: "address" },
|
||||
{ name: "roles", type: "uint256", internalType: "uint256" },
|
||||
],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "rolesOf",
|
||||
inputs: [{ name: "user", type: "address", internalType: "address" }],
|
||||
outputs: [{ name: "roles", type: "uint256", internalType: "uint256" }],
|
||||
stateMutability: "view",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "supportsInterface",
|
||||
inputs: [{ name: "interfaceId", type: "bytes4", internalType: "bytes4" }],
|
||||
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
||||
stateMutability: "view",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "transferOwnership",
|
||||
inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "function",
|
||||
name: "uninstallExtension",
|
||||
inputs: [
|
||||
{ name: "_extension", type: "address", internalType: "address" },
|
||||
{ name: "_data", type: "bytes", internalType: "bytes" },
|
||||
],
|
||||
outputs: [],
|
||||
stateMutability: "payable",
|
||||
},
|
||||
{
|
||||
type: "event",
|
||||
name: "ExtensionInstalled",
|
||||
inputs: [
|
||||
{
|
||||
name: "caller",
|
||||
type: "address",
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "implementation",
|
||||
type: "address",
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "installedExtension",
|
||||
type: "address",
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
},
|
||||
],
|
||||
anonymous: false,
|
||||
},
|
||||
{
|
||||
type: "event",
|
||||
name: "ExtensionUninstalled",
|
||||
inputs: [
|
||||
{
|
||||
name: "caller",
|
||||
type: "address",
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "implementation",
|
||||
type: "address",
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "installedExtension",
|
||||
type: "address",
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
},
|
||||
],
|
||||
anonymous: false,
|
||||
},
|
||||
{
|
||||
type: "event",
|
||||
name: "OwnershipHandoverCanceled",
|
||||
inputs: [
|
||||
{
|
||||
name: "pendingOwner",
|
||||
type: "address",
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
},
|
||||
],
|
||||
anonymous: false,
|
||||
},
|
||||
{
|
||||
type: "event",
|
||||
name: "OwnershipHandoverRequested",
|
||||
inputs: [
|
||||
{
|
||||
name: "pendingOwner",
|
||||
type: "address",
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
},
|
||||
],
|
||||
anonymous: false,
|
||||
},
|
||||
{
|
||||
type: "event",
|
||||
name: "OwnershipTransferred",
|
||||
inputs: [
|
||||
{
|
||||
name: "oldOwner",
|
||||
type: "address",
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
},
|
||||
],
|
||||
anonymous: false,
|
||||
},
|
||||
{
|
||||
type: "event",
|
||||
name: "RolesUpdated",
|
||||
inputs: [
|
||||
{
|
||||
name: "user",
|
||||
type: "address",
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "roles",
|
||||
type: "uint256",
|
||||
indexed: true,
|
||||
internalType: "uint256",
|
||||
},
|
||||
],
|
||||
anonymous: false,
|
||||
},
|
||||
{ type: "error", name: "AlreadyInitialized", inputs: [] },
|
||||
{ type: "error", name: "CallbackExecutionReverted", inputs: [] },
|
||||
{
|
||||
type: "error",
|
||||
name: "CallbackFunctionAlreadyInstalled",
|
||||
inputs: [],
|
||||
},
|
||||
{ type: "error", name: "CallbackFunctionNotSupported", inputs: [] },
|
||||
{ type: "error", name: "CallbackFunctionRequired", inputs: [] },
|
||||
{
|
||||
type: "error",
|
||||
name: "CallbackFunctionUnauthorizedCall",
|
||||
inputs: [],
|
||||
},
|
||||
{ type: "error", name: "ExtensionAlreadyInstalled", inputs: [] },
|
||||
{
|
||||
type: "error",
|
||||
name: "ExtensionInterfaceNotCompatible",
|
||||
inputs: [
|
||||
{
|
||||
name: "requiredInterfaceId",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
],
|
||||
},
|
||||
{ type: "error", name: "ExtensionNotInstalled", inputs: [] },
|
||||
{ type: "error", name: "ExtensionOutOfSync", inputs: [] },
|
||||
{
|
||||
type: "error",
|
||||
name: "FallbackFunctionAlreadyInstalled",
|
||||
inputs: [],
|
||||
},
|
||||
{ type: "error", name: "FallbackFunctionNotInstalled", inputs: [] },
|
||||
{ type: "error", name: "IndexOutOfBounds", inputs: [] },
|
||||
{ type: "error", name: "NewOwnerIsZeroAddress", inputs: [] },
|
||||
{ type: "error", name: "NoHandoverRequest", inputs: [] },
|
||||
{ type: "error", name: "Unauthorized", inputs: [] },
|
||||
];
|
||||
|
||||
export const extensionContractAbi = [
|
||||
{
|
||||
type: "function",
|
||||
name: "getExtensionConfig",
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
name: "",
|
||||
type: "tuple",
|
||||
internalType: "struct IExtensionConfig.ExtensionConfig",
|
||||
components: [
|
||||
{
|
||||
name: "registerInstallationCallback",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
{
|
||||
name: "requiredInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "supportedInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "callbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.CallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "fallbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.FallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
{
|
||||
name: "permissionBits",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
stateMutability: "pure",
|
||||
},
|
||||
];
|
||||
|
||||
export const FEATURE_ROYALTY = {
|
||||
name: "Royalty",
|
||||
namespace: "royalty",
|
||||
@@ -255,6 +699,30 @@ export const FEATURE_DYNAMIC_CONTRACT = {
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
export const FEATURE_MODULAR_CORE = {
|
||||
name: "ModularCore",
|
||||
namespace: "modular.core",
|
||||
docLinks: {
|
||||
sdk: "",
|
||||
//TODO
|
||||
contracts: "",
|
||||
},
|
||||
abis: [coreContractAbi],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
export const FEATURE_MODULAR_EXTENSION = {
|
||||
name: "ModularExtension",
|
||||
namespace: "modular.extension",
|
||||
docLinks: {
|
||||
sdk: "",
|
||||
//TODO
|
||||
contracts: "",
|
||||
},
|
||||
abis: [extensionContractAbi],
|
||||
features: {},
|
||||
} as const;
|
||||
|
||||
export const FEATURE_DIRECT_LISTINGS = {
|
||||
name: "DirectListings",
|
||||
namespace: "direct.listings",
|
||||
|
||||
@@ -406,11 +406,18 @@ export class ContractPublisher extends RPCConnectionHandler {
|
||||
"DynamicContract",
|
||||
features,
|
||||
);
|
||||
const isModular = isFeatureEnabled(
|
||||
compilerMetadata.abi,
|
||||
"ModularCore",
|
||||
features,
|
||||
);
|
||||
extraMetadataCleaned.routerType = isPlugin
|
||||
? "plugin"
|
||||
: isDynamic
|
||||
? "dynamic"
|
||||
: "none";
|
||||
: isModular
|
||||
? "modular"
|
||||
: "none";
|
||||
|
||||
// For a dynamic contract Router, try to fetch plugin/extension metadata
|
||||
if (isDynamic || isPlugin) {
|
||||
|
||||
@@ -102,6 +102,7 @@ export * from "./common/feature-detection/detectContractFeature";
|
||||
export * from "./common/feature-detection/hasFunction";
|
||||
export * from "./common/plugin/joinABIs";
|
||||
export * from "./common/plugin/getCompositePluginABI";
|
||||
export * from "./common/modular/compatibleExtensions";
|
||||
export * from "./common/version-checker";
|
||||
export * from "./common/fetchSourceFilesFromMetadata";
|
||||
export { isNativeToken } from "./common/currency/isNativeToken";
|
||||
|
||||
@@ -166,6 +166,14 @@ export const CustomFactoryInput = /* @__PURE__ */ (() =>
|
||||
customFactoryAddresses: ChainIdToAddressSchema,
|
||||
}))();
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const ModularFactoryInput = /* @__PURE__ */ (() =>
|
||||
z.object({
|
||||
hooksParamName: z.string(),
|
||||
}))();
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@@ -174,6 +182,7 @@ export const FactoryDeploymentSchema = /* @__PURE__ */ (() =>
|
||||
implementationAddresses: ChainIdToAddressSchema,
|
||||
implementationInitializerFunction: z.string().default("initialize"),
|
||||
customFactoryInput: CustomFactoryInput.optional(),
|
||||
modularFactoryInput: ModularFactoryInput.optional(),
|
||||
factoryAddresses: ChainIdToAddressSchema.optional(),
|
||||
}))();
|
||||
|
||||
@@ -191,7 +200,12 @@ export const DeployTypeInput = /* @__PURE__ */ (() =>
|
||||
* @internal
|
||||
*/
|
||||
export const RouterTypeInput = /* @__PURE__ */ (() =>
|
||||
z.union([z.literal("none"), z.literal("plugin"), z.literal("dynamic")]))();
|
||||
z.union([
|
||||
z.literal("none"),
|
||||
z.literal("plugin"),
|
||||
z.literal("dynamic"),
|
||||
z.literal("modular"),
|
||||
]))();
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
export const mockExtensionWithInterfaceBytecode = "0x6080604052348015600f57600080fd5b506106f08061001f6000396000f3fe608060405234801561001057600080fd5b50600436106100de5760003560e01c80637c173ecc1161008c5780638dc5fd9e116100665780638dc5fd9e146100e3578063ae7c8cb7146100e3578063edf8bf0514610141578063f2c9ecd81461014957600080fd5b80637c173ecc1461012c57806389242efb146100e35780638a91b0e31461010057600080fd5b80633fb5c1cb116100bd5780633fb5c1cb146100ed5780636d61fe7014610100578063774237fc1461011157600080fd5b8062862ba3146100e35780630a340d43146100e357806313efddd6146100e5575b600080fd5b005b6100e3610151565b6100e36100fb366004610388565b600055565b6100e361010e3660046103d0565b50565b610119602081565b6040519081526020015b60405180910390f35b61013461017c565b604051610123919061055b565b6100e3610249565b600054610119565b6040517f6a94d761ae01a14a6739229452f57b368e87612171065a3d5019e116a9d396f290600090a1565b6101b06040518060a00160405280600015158152602001606081526020016060815260200160608152602001606081525090565b6101b8610274565b606082015260408051600180825281830190925290602080830190803683375050506020820181905280517f123456780000000000000000000000000000000000000000000000000000000091906000906102155761021561064b565b7fffffffff000000000000000000000000000000000000000000000000000000009092166020928302919091019091015290565b6040517f79201cdedb9b351e17bd1274b3465126723ac336d7a6b1546a2f0e97b8f0a73090600090a1565b6060610282600a600161067a565b67ffffffffffffffff81111561029a5761029a6103a1565b6040519080825280602002602001820160405280156102da57816020015b6040805160208101909152600081528152602001906001900390816102b85790505b50905060005b600a811015610338578060e01b8282815181106102ff576102ff61064b565b60209081029190910101517fffffffff0000000000000000000000000000000000000000000000000000000090911690526001016102e0565b5063edf8bf0560e01b81600a815181106103545761035461064b565b60209081029190910101517fffffffff00000000000000000000000000000000000000000000000000000000909116905290565b60006020828403121561039a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000602082840312156103e257600080fd5b813567ffffffffffffffff808211156103fa57600080fd5b818401915084601f83011261040e57600080fd5b813581811115610420576104206103a1565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715610466576104666103a1565b8160405282815287602084870101111561047f57600080fd5b826020860160208301376000928101602001929092525095945050505050565b60008151808452602080850194506020840160005b838110156104f25781517fffffffff0000000000000000000000000000000000000000000000000000000016875295820195908201906001016104b4565b509495945050505050565b60008151808452602080850194506020840160005b838110156104f257815180517fffffffff000000000000000000000000000000000000000000000000000000001688528301518388015260409096019590820190600101610512565b6000602080835283511515818401528084015160a0604085015261058260c085018261049f565b905060408501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0808684030160608701526105be838361049f565b6060880151878203830160808901528051808352908601945060009350908501905b80841015610623578451517fffffffff000000000000000000000000000000000000000000000000000000001682529385019360019390930192908501906105e0565b5060808801519450818782030160a088015261063f81866104fd565b98975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b808201808211156106b4577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b9291505056fea26469706673582212201665fc4a987397715b9892065ad27121276fc1052ea227a5f5cff3da42d5c25764736f6c63430008190033";
|
||||
@@ -0,0 +1,144 @@
|
||||
import {
|
||||
extendedMetadataMock,
|
||||
jsonProvider,
|
||||
signers,
|
||||
sdk,
|
||||
} from "./before-setup";
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { mockUploadMetadataWithBytecode } from "./utils";
|
||||
import {
|
||||
mockCoreBytecode,
|
||||
mockCoreCompilerMetadata,
|
||||
mockCoreDeployedBytecode,
|
||||
} from "./mock/mockCoreMetadata";
|
||||
import {
|
||||
mockExtensionWithFunctionsBytecode,
|
||||
mockExtensionWithFunctionsCompilerMetadata,
|
||||
} from "./mock/mockExtensionWithFunctionsMetadata";
|
||||
import { compatibleExtensions } from "../../src/evm/common/modular/compatibleExtensions";
|
||||
import { mockExtensionWithInterfaceBytecode } from "./mock/mockExtensionWithInterface";
|
||||
|
||||
describe("Modular contract deployment", async () => {
|
||||
let adminWallet: SignerWithAddress;
|
||||
|
||||
async function mockPublishExtension() {
|
||||
const mockPublisher = process.env.contractPublisherAddress;
|
||||
process.env.contractPublisherAddress =
|
||||
"0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808";
|
||||
|
||||
const publishUri = await mockUploadMetadataWithBytecode(
|
||||
"DemoExtensionWithFunctions",
|
||||
mockExtensionWithFunctionsCompilerMetadata.output.abi,
|
||||
mockExtensionWithFunctionsBytecode,
|
||||
"",
|
||||
{
|
||||
...extendedMetadataMock,
|
||||
deployType: "standard",
|
||||
networksForDeployment: {
|
||||
allNetworks: true,
|
||||
networksEnabled: [],
|
||||
},
|
||||
publisher: await adminWallet.getAddress(),
|
||||
},
|
||||
"ipfs://QmbAYkPwB2V8E8Phs62TFAoAa9fuP74DZFD2uCiSNAHpVb/0",
|
||||
);
|
||||
|
||||
process.env.contractPublisherAddress = mockPublisher;
|
||||
|
||||
return publishUri;
|
||||
}
|
||||
|
||||
async function mockPublishAndDeployMockCore() {
|
||||
const mockPublisher = process.env.contractPublisherAddress;
|
||||
process.env.contractPublisherAddress =
|
||||
"0xf5b896Ddb5146D5dA77efF4efBb3Eae36E300808";
|
||||
|
||||
const publishUri = await mockUploadMetadataWithBytecode(
|
||||
"DemoCore",
|
||||
mockCoreCompilerMetadata.output.abi,
|
||||
mockCoreBytecode,
|
||||
mockCoreDeployedBytecode,
|
||||
{
|
||||
...extendedMetadataMock,
|
||||
deployType: "autoFactory",
|
||||
routerType: "modular",
|
||||
defaultExtensions: [
|
||||
{
|
||||
extensionName: "DemoExtensionWithFunctions",
|
||||
extensionVersion: "",
|
||||
publisherAddress: await adminWallet.getAddress(),
|
||||
},
|
||||
],
|
||||
factoryDeploymentData: {
|
||||
implementationAddresses: {},
|
||||
factoryAddresses: {},
|
||||
implementationInitializerFunction: "initialize",
|
||||
|
||||
modularFactoryInput: { hooksParamName: "extensions" },
|
||||
},
|
||||
networksForDeployment: {
|
||||
allNetworks: true,
|
||||
networksEnabled: [],
|
||||
},
|
||||
publisher: await adminWallet.getAddress(),
|
||||
},
|
||||
"ipfs://QmbQLyXkhkF2tF6nSbB9TaXUShaLbEWMi11zuR5U5mfz2X/0",
|
||||
);
|
||||
|
||||
const walletAddress = await sdk.wallet.getAddress();
|
||||
|
||||
const address = await sdk.deployer.deployContractFromUri(
|
||||
publishUri,
|
||||
[walletAddress, [], ["0x"]],
|
||||
{
|
||||
forceDirectDeploy: false,
|
||||
},
|
||||
);
|
||||
|
||||
const core = await sdk.getContract(address);
|
||||
|
||||
process.env.contractPublisherAddress = mockPublisher;
|
||||
|
||||
return core;
|
||||
}
|
||||
|
||||
before(async () => {
|
||||
[adminWallet] = signers;
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
sdk.updateSignerOrProvider(adminWallet);
|
||||
await jsonProvider.send("hardhat_reset", []);
|
||||
});
|
||||
|
||||
it("should deploy core but not install hooks", async () => {
|
||||
// await mockPublishModularFactory();
|
||||
await mockPublishExtension();
|
||||
const mockCore = await mockPublishAndDeployMockCore();
|
||||
|
||||
const extensions = await mockCore.call("getInstalledExtensions");
|
||||
|
||||
expect(extensions.length).to.equal(0);
|
||||
});
|
||||
|
||||
it("should check extension compatibility", async () => {
|
||||
// duplicate callback/fallback
|
||||
let isCompatible = await compatibleExtensions(
|
||||
mockCoreBytecode,
|
||||
[mockExtensionWithFunctionsBytecode, mockExtensionWithFunctionsBytecode],
|
||||
11155111,
|
||||
);
|
||||
|
||||
expect(isCompatible).to.be.false;
|
||||
|
||||
// required interface not supported
|
||||
isCompatible = await compatibleExtensions(
|
||||
mockCoreBytecode,
|
||||
[mockExtensionWithInterfaceBytecode],
|
||||
11155111,
|
||||
);
|
||||
|
||||
expect(isCompatible).to.be.false;
|
||||
});
|
||||
});
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,14 @@
|
||||
# @thirdweb-dev/unity-js-bridge
|
||||
|
||||
## 0.6.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`7768067`](https://github.com/thirdweb-dev/js/commit/7768067bf4f571a8c8ee6b646a58e2fc5f6bd052)]:
|
||||
- @thirdweb-dev/sdk@4.0.95
|
||||
- @thirdweb-dev/wallets@2.5.35
|
||||
- @thirdweb-dev/auth@4.1.93
|
||||
|
||||
## 0.6.43
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/unity-js-bridge",
|
||||
"version": "0.6.43",
|
||||
"version": "0.6.44",
|
||||
"main": "dist/thirdweb-unity-bridge.js",
|
||||
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/unity-js-bridge",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @thirdweb-dev/wallets
|
||||
|
||||
## 2.5.35
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`7768067`](https://github.com/thirdweb-dev/js/commit/7768067bf4f571a8c8ee6b646a58e2fc5f6bd052)]:
|
||||
- @thirdweb-dev/sdk@4.0.95
|
||||
|
||||
## 2.5.34
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@thirdweb-dev/wallets",
|
||||
"version": "2.5.34",
|
||||
"version": "2.5.35",
|
||||
"main": "dist/thirdweb-dev-wallets.cjs.js",
|
||||
"module": "dist/thirdweb-dev-wallets.esm.js",
|
||||
"browser": {
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,13 @@
|
||||
# thirdweb
|
||||
|
||||
## 5.29.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#2880](https://github.com/thirdweb-dev/js/pull/2880) [`7768067`](https://github.com/thirdweb-dev/js/commit/7768067bf4f571a8c8ee6b646a58e2fc5f6bd052) Thanks [@kumaryash90](https://github.com/kumaryash90)! - Modular contract publish and deploy setup
|
||||
|
||||
- [#3318](https://github.com/thirdweb-dev/js/pull/3318) [`fb6a07d`](https://github.com/thirdweb-dev/js/commit/fb6a07d4b84ba8ea6389ca04c73625f670a0d9c4) Thanks [@jnsdls](https://github.com/jnsdls)! - add missing erc4337 extensions
|
||||
|
||||
## 5.29.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "thirdweb",
|
||||
"version": "5.29.1",
|
||||
"version": "5.29.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/thirdweb-dev/js.git#main"
|
||||
@@ -258,7 +258,7 @@
|
||||
"scripts": {
|
||||
"bench:compare": "bun run ./benchmarks/run.ts",
|
||||
"bench": "vitest -c ./test/vitest.config.ts bench",
|
||||
"format": "biome format 'src/**/*' --write",
|
||||
"format": "biome format src/ --write",
|
||||
"lint": "biome check src/",
|
||||
"fix": "biome check src/ --apply",
|
||||
"knip": "knip",
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
"function getAccountsOfSigner(address signer) view returns (address[] accounts)",
|
||||
"function getAddress(address adminSigner, bytes data) view returns (address)",
|
||||
"function getAllAccounts() view returns (address[])",
|
||||
"function getAccounts(uint256 start, uint256 end) view returns (address[])",
|
||||
"function onSignerAdded(address signer, address creatorAdmin, bytes data)",
|
||||
"function onSignerRemoved(address signer, address creatorAdmin, bytes data)"
|
||||
"function onSignerRemoved(address signer, address creatorAdmin, bytes data)",
|
||||
"function totalAccounts() view returns (uint256)",
|
||||
"function isRegistered(address account) view returns (bool)"
|
||||
]
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
[
|
||||
{
|
||||
"type": "function",
|
||||
"name": "getInstalledExtensions",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IModularCore.InstalledExtension[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "implementation",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "config",
|
||||
"type": "tuple",
|
||||
"internalType": "struct IExtensionConfig.ExtensionConfig",
|
||||
"components": [
|
||||
{
|
||||
"name": "registerInstallationCallback",
|
||||
"type": "bool",
|
||||
"internalType": "bool"
|
||||
},
|
||||
{
|
||||
"name": "requiredInterfaces",
|
||||
"type": "bytes4[]",
|
||||
"internalType": "bytes4[]"
|
||||
},
|
||||
{
|
||||
"name": "supportedInterfaces",
|
||||
"type": "bytes4[]",
|
||||
"internalType": "bytes4[]"
|
||||
},
|
||||
{
|
||||
"name": "callbackFunctions",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IExtensionConfig.CallbackFunction[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "selector",
|
||||
"type": "bytes4",
|
||||
"internalType": "bytes4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "fallbackFunctions",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IExtensionConfig.FallbackFunction[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "selector",
|
||||
"type": "bytes4",
|
||||
"internalType": "bytes4"
|
||||
},
|
||||
{
|
||||
"name": "permissionBits",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "getSupportedCallbackFunctions",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IModularCore.SupportedCallbackFunction[]",
|
||||
"components": [
|
||||
{ "name": "selector", "type": "bytes4", "internalType": "bytes4" },
|
||||
{
|
||||
"name": "mode",
|
||||
"type": "uint8",
|
||||
"internalType": "enum IModularCore.CallbackMode"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "installExtension",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "extensionContract",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{ "name": "data", "type": "bytes", "internalType": "bytes" }
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "supportsInterface",
|
||||
"inputs": [
|
||||
{ "name": "interfaceID", "type": "bytes4", "internalType": "bytes4" }
|
||||
],
|
||||
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "uninstallExtension",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "extensionContract",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{ "name": "data", "type": "bytes", "internalType": "bytes" }
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,61 @@
|
||||
[
|
||||
{
|
||||
"type": "function",
|
||||
"name": "getExtensionConfig",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "tuple",
|
||||
"internalType": "struct IExtensionConfig.ExtensionConfig",
|
||||
"components": [
|
||||
{
|
||||
"name": "registerInstallationCallback",
|
||||
"type": "bool",
|
||||
"internalType": "bool"
|
||||
},
|
||||
{
|
||||
"name": "requiredInterfaces",
|
||||
"type": "bytes4[]",
|
||||
"internalType": "bytes4[]"
|
||||
},
|
||||
{
|
||||
"name": "supportedInterfaces",
|
||||
"type": "bytes4[]",
|
||||
"internalType": "bytes4[]"
|
||||
},
|
||||
{
|
||||
"name": "callbackFunctions",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IExtensionConfig.CallbackFunction[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "selector",
|
||||
"type": "bytes4",
|
||||
"internalType": "bytes4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "fallbackFunctions",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IExtensionConfig.FallbackFunction[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "selector",
|
||||
"type": "bytes4",
|
||||
"internalType": "bytes4"
|
||||
},
|
||||
{
|
||||
"name": "permissionBits",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,395 @@
|
||||
[
|
||||
{ "type": "fallback", "stateMutability": "payable" },
|
||||
{
|
||||
"type": "function",
|
||||
"name": "cancelOwnershipHandover",
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "completeOwnershipHandover",
|
||||
"inputs": [
|
||||
{ "name": "pendingOwner", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "getInstalledExtensions",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "_installedExtensions",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IModularCore.InstalledExtension[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "implementation",
|
||||
"type": "address",
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "config",
|
||||
"type": "tuple",
|
||||
"internalType": "struct IExtensionConfig.ExtensionConfig",
|
||||
"components": [
|
||||
{
|
||||
"name": "registerInstallationCallback",
|
||||
"type": "bool",
|
||||
"internalType": "bool"
|
||||
},
|
||||
{
|
||||
"name": "requiredInterfaces",
|
||||
"type": "bytes4[]",
|
||||
"internalType": "bytes4[]"
|
||||
},
|
||||
{
|
||||
"name": "supportedInterfaces",
|
||||
"type": "bytes4[]",
|
||||
"internalType": "bytes4[]"
|
||||
},
|
||||
{
|
||||
"name": "callbackFunctions",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IExtensionConfig.CallbackFunction[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "selector",
|
||||
"type": "bytes4",
|
||||
"internalType": "bytes4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "fallbackFunctions",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IExtensionConfig.FallbackFunction[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "selector",
|
||||
"type": "bytes4",
|
||||
"internalType": "bytes4"
|
||||
},
|
||||
{
|
||||
"name": "permissionBits",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "getSupportedCallbackFunctions",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IModularCore.SupportedCallbackFunction[]",
|
||||
"components": [
|
||||
{ "name": "selector", "type": "bytes4", "internalType": "bytes4" },
|
||||
{
|
||||
"name": "mode",
|
||||
"type": "uint8",
|
||||
"internalType": "enum IModularCore.CallbackMode"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "grantRoles",
|
||||
"inputs": [
|
||||
{ "name": "user", "type": "address", "internalType": "address" },
|
||||
{ "name": "roles", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "hasAllRoles",
|
||||
"inputs": [
|
||||
{ "name": "user", "type": "address", "internalType": "address" },
|
||||
{ "name": "roles", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "hasAnyRole",
|
||||
"inputs": [
|
||||
{ "name": "user", "type": "address", "internalType": "address" },
|
||||
{ "name": "roles", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "installExtension",
|
||||
"inputs": [
|
||||
{ "name": "_extension", "type": "address", "internalType": "address" },
|
||||
{ "name": "_data", "type": "bytes", "internalType": "bytes" }
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "owner",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{ "name": "result", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "ownershipHandoverExpiresAt",
|
||||
"inputs": [
|
||||
{ "name": "pendingOwner", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"outputs": [
|
||||
{ "name": "result", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "renounceOwnership",
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "renounceRoles",
|
||||
"inputs": [
|
||||
{ "name": "roles", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "requestOwnershipHandover",
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "revokeRoles",
|
||||
"inputs": [
|
||||
{ "name": "user", "type": "address", "internalType": "address" },
|
||||
{ "name": "roles", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "rolesOf",
|
||||
"inputs": [
|
||||
{ "name": "user", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"outputs": [
|
||||
{ "name": "roles", "type": "uint256", "internalType": "uint256" }
|
||||
],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "supportsInterface",
|
||||
"inputs": [
|
||||
{ "name": "interfaceId", "type": "bytes4", "internalType": "bytes4" }
|
||||
],
|
||||
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
|
||||
"stateMutability": "view"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "transferOwnership",
|
||||
"inputs": [
|
||||
{ "name": "newOwner", "type": "address", "internalType": "address" }
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"name": "uninstallExtension",
|
||||
"inputs": [
|
||||
{ "name": "_extension", "type": "address", "internalType": "address" },
|
||||
{ "name": "_data", "type": "bytes", "internalType": "bytes" }
|
||||
],
|
||||
"outputs": [],
|
||||
"stateMutability": "payable"
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "ExtensionInstalled",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "caller",
|
||||
"type": "address",
|
||||
"indexed": false,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "implementation",
|
||||
"type": "address",
|
||||
"indexed": false,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "installedExtension",
|
||||
"type": "address",
|
||||
"indexed": false,
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "ExtensionUninstalled",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "caller",
|
||||
"type": "address",
|
||||
"indexed": false,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "implementation",
|
||||
"type": "address",
|
||||
"indexed": false,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "installedExtension",
|
||||
"type": "address",
|
||||
"indexed": false,
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "OwnershipHandoverCanceled",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "pendingOwner",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "OwnershipHandoverRequested",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "pendingOwner",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "OwnershipTransferred",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "oldOwner",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{
|
||||
"type": "event",
|
||||
"name": "RolesUpdated",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "user",
|
||||
"type": "address",
|
||||
"indexed": true,
|
||||
"internalType": "address"
|
||||
},
|
||||
{
|
||||
"name": "roles",
|
||||
"type": "uint256",
|
||||
"indexed": true,
|
||||
"internalType": "uint256"
|
||||
}
|
||||
],
|
||||
"anonymous": false
|
||||
},
|
||||
{ "type": "error", "name": "AlreadyInitialized", "inputs": [] },
|
||||
{ "type": "error", "name": "CallbackExecutionReverted", "inputs": [] },
|
||||
{
|
||||
"type": "error",
|
||||
"name": "CallbackFunctionAlreadyInstalled",
|
||||
"inputs": []
|
||||
},
|
||||
{ "type": "error", "name": "CallbackFunctionNotSupported", "inputs": [] },
|
||||
{ "type": "error", "name": "CallbackFunctionRequired", "inputs": [] },
|
||||
{
|
||||
"type": "error",
|
||||
"name": "CallbackFunctionUnauthorizedCall",
|
||||
"inputs": []
|
||||
},
|
||||
{ "type": "error", "name": "ExtensionAlreadyInstalled", "inputs": [] },
|
||||
{
|
||||
"type": "error",
|
||||
"name": "ExtensionInterfaceNotCompatible",
|
||||
"inputs": [
|
||||
{
|
||||
"name": "requiredInterfaceId",
|
||||
"type": "bytes4",
|
||||
"internalType": "bytes4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "type": "error", "name": "ExtensionNotInstalled", "inputs": [] },
|
||||
{ "type": "error", "name": "ExtensionOutOfSync", "inputs": [] },
|
||||
{
|
||||
"type": "error",
|
||||
"name": "FallbackFunctionAlreadyInstalled",
|
||||
"inputs": []
|
||||
},
|
||||
{ "type": "error", "name": "FallbackFunctionNotInstalled", "inputs": [] },
|
||||
{ "type": "error", "name": "IndexOutOfBounds", "inputs": [] },
|
||||
{ "type": "error", "name": "NewOwnerIsZeroAddress", "inputs": [] },
|
||||
{ "type": "error", "name": "NoHandoverRequest", "inputs": [] },
|
||||
{ "type": "error", "name": "Unauthorized", "inputs": [] }
|
||||
]
|
||||
@@ -0,0 +1,61 @@
|
||||
[
|
||||
{
|
||||
"type": "function",
|
||||
"name": "getExtensionConfig",
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "tuple",
|
||||
"internalType": "struct IExtensionConfig.ExtensionConfig",
|
||||
"components": [
|
||||
{
|
||||
"name": "registerInstallationCallback",
|
||||
"type": "bool",
|
||||
"internalType": "bool"
|
||||
},
|
||||
{
|
||||
"name": "requiredInterfaces",
|
||||
"type": "bytes4[]",
|
||||
"internalType": "bytes4[]"
|
||||
},
|
||||
{
|
||||
"name": "supportedInterfaces",
|
||||
"type": "bytes4[]",
|
||||
"internalType": "bytes4[]"
|
||||
},
|
||||
{
|
||||
"name": "callbackFunctions",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IExtensionConfig.CallbackFunction[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "selector",
|
||||
"type": "bytes4",
|
||||
"internalType": "bytes4"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "fallbackFunctions",
|
||||
"type": "tuple[]",
|
||||
"internalType": "struct IExtensionConfig.FallbackFunction[]",
|
||||
"components": [
|
||||
{
|
||||
"name": "selector",
|
||||
"type": "bytes4",
|
||||
"internalType": "bytes4"
|
||||
},
|
||||
{
|
||||
"name": "permissionBits",
|
||||
"type": "uint256",
|
||||
"internalType": "uint256"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure"
|
||||
}
|
||||
]
|
||||
@@ -55,8 +55,9 @@ export async function generateFromAbi(
|
||||
events.map(async (e) => {
|
||||
await writeFile(
|
||||
join(outFolder, extensionFileName, "./events", `${e.name}.ts`),
|
||||
await format(generateEvent(e, extensionName), {
|
||||
format(generateEvent(e, extensionName), {
|
||||
parser: "babel-ts",
|
||||
trailingComma: "all",
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
@@ -73,8 +74,9 @@ export async function generateFromAbi(
|
||||
readFunctions.map(async (f) => {
|
||||
await writeFile(
|
||||
join(outFolder, extensionFileName, "./read", `${f.name}.ts`),
|
||||
await format(generateReadFunction(f, extensionName), {
|
||||
format(generateReadFunction(f, extensionName), {
|
||||
parser: "babel-ts",
|
||||
trailingComma: "all",
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
@@ -91,8 +93,9 @@ export async function generateFromAbi(
|
||||
writeFunctions.map(async (f) => {
|
||||
await writeFile(
|
||||
join(outFolder, extensionFileName, "./write", `${f.name}.ts`),
|
||||
await format(generateWriteFunction(f, extensionName), {
|
||||
format(generateWriteFunction(f, extensionName), {
|
||||
parser: "babel-ts",
|
||||
trailingComma: "all",
|
||||
}),
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { type Abi, formatAbi, parseAbi } from "abitype";
|
||||
import { getInstalledExtensions } from "../../extensions/modular/__generated__/ModularCore/read/getInstalledExtensions.js";
|
||||
import { download } from "../../storage/download.js";
|
||||
import { extractIPFSUri } from "../../utils/bytecode/extractIPFS.js";
|
||||
import { getClientFetch } from "../../utils/fetch.js";
|
||||
@@ -284,12 +285,14 @@ export async function resolveCompositeAbi(
|
||||
rootAbi_,
|
||||
pluginPatternAddresses,
|
||||
baseRouterAddresses,
|
||||
modularExtensionAddresses,
|
||||
diamondFacetAddresses,
|
||||
] = await Promise.all([
|
||||
rootAbi ? rootAbi : resolveAbiFromBytecode(contract),
|
||||
// check these all at the same time
|
||||
resolvePluginPatternAddresses(contract),
|
||||
resolveBaseRouterAddresses(contract),
|
||||
resolveModularExtensionAddresses(contract),
|
||||
resolveDiamondFacetAddresses(contract),
|
||||
]);
|
||||
|
||||
@@ -297,6 +300,7 @@ export async function resolveCompositeAbi(
|
||||
...new Set([
|
||||
...pluginPatternAddresses,
|
||||
...baseRouterAddresses,
|
||||
...modularExtensionAddresses,
|
||||
...diamondFacetAddresses,
|
||||
]),
|
||||
];
|
||||
@@ -358,6 +362,23 @@ async function resolveBaseRouterAddresses(
|
||||
return [];
|
||||
}
|
||||
|
||||
async function resolveModularExtensionAddresses(
|
||||
contract: ThirdwebContract,
|
||||
): Promise<string[]> {
|
||||
try {
|
||||
const extensions = await getInstalledExtensions({ contract });
|
||||
// if there are no plugins, return the root ABI
|
||||
if (!extensions.length) {
|
||||
return [];
|
||||
}
|
||||
// get all the plugin addresses
|
||||
return [...new Set(extensions.map((item) => item.implementation))];
|
||||
} catch {
|
||||
// no-op, expected because not everything supports this
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
async function resolveDiamondFacetAddresses(
|
||||
contract: ThirdwebContract,
|
||||
): Promise<string[]> {
|
||||
|
||||
@@ -21,6 +21,13 @@ export {
|
||||
checkVerificationStatus,
|
||||
} from "../contract/verification/index.js";
|
||||
|
||||
// publisher
|
||||
export {
|
||||
fetchPublishedContract,
|
||||
fetchPublishedContractMetadata,
|
||||
fetchDeployBytecodeFromPublishedContractMetadata,
|
||||
} from "../contract/deployment/publisher.js";
|
||||
|
||||
// deployment - TODO: these end up looking more like extensions -> should they be?
|
||||
export {
|
||||
prepareDirectDeployTransaction,
|
||||
|
||||
@@ -36,6 +36,9 @@ export { signerPermissionsUpdatedEvent } from "../../extensions/erc4337/__genera
|
||||
|
||||
// FACTORY
|
||||
export { getAllAccounts } from "../../extensions/erc4337/__generated__/IAccountFactory/read/getAllAccounts.js";
|
||||
export { getAccounts } from "../../extensions/erc4337/__generated__/IAccountFactory/read/getAccounts.js";
|
||||
export { totalAccounts } from "../../extensions/erc4337/__generated__/IAccountFactory/read/totalAccounts.js";
|
||||
export { isRegistered } from "../../extensions/erc4337/__generated__/IAccountFactory/read/isRegistered.js";
|
||||
export {
|
||||
getAccountsOfSigner,
|
||||
type GetAccountsOfSignerParams,
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* READ
|
||||
*/
|
||||
export {
|
||||
getInstalledExtensions,
|
||||
isGetInstalledExtensionsSupported,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/read/getInstalledExtensions.js";
|
||||
export {
|
||||
getSupportedCallbackFunctions,
|
||||
isGetSupportedCallbackFunctionsSupported,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/read/getSupportedCallbackFunctions.js";
|
||||
export {
|
||||
hasAnyRole,
|
||||
type HasAnyRoleParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/read/hasAnyRole.js";
|
||||
export {
|
||||
hasAllRoles,
|
||||
type HasAllRolesParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/read/hasAllRoles.js";
|
||||
export { owner } from "../../extensions/modular/__generated__/ModularCore/read/owner.js";
|
||||
export {
|
||||
ownershipHandoverExpiresAt,
|
||||
type OwnershipHandoverExpiresAtParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/read/ownershipHandoverExpiresAt.js";
|
||||
export {
|
||||
rolesOf,
|
||||
type RolesOfParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/read/rolesOf.js";
|
||||
|
||||
/**
|
||||
* Write
|
||||
*/
|
||||
export { cancelOwnershipHandover } from "../../extensions/modular/__generated__/ModularCore/write/cancelOwnershipHandover.js";
|
||||
export {
|
||||
completeOwnershipHandover,
|
||||
type CompleteOwnershipHandoverParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/write/completeOwnershipHandover.js";
|
||||
export {
|
||||
grantRoles,
|
||||
type GrantRolesParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/write/grantRoles.js";
|
||||
export {
|
||||
installExtension,
|
||||
isInstallExtensionSupported,
|
||||
type InstallExtensionParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/write/installExtension.js";
|
||||
export { renounceOwnership } from "../../extensions/modular/__generated__/ModularCore/write/renounceOwnership.js";
|
||||
export { requestOwnershipHandover } from "../../extensions/modular/__generated__/ModularCore/write/requestOwnershipHandover.js";
|
||||
export {
|
||||
renounceRoles,
|
||||
type RenounceRolesParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/write/renounceRoles.js";
|
||||
export {
|
||||
revokeRoles,
|
||||
type RevokeRolesParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/write/revokeRoles.js";
|
||||
export {
|
||||
transferOwnership,
|
||||
type TransferOwnershipParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/write/transferOwnership.js";
|
||||
export {
|
||||
uninstallExtension,
|
||||
isUninstallExtensionSupported,
|
||||
type UninstallExtensionParams,
|
||||
} from "../../extensions/modular/__generated__/ModularCore/write/uninstallExtension.js";
|
||||
export { getExtensionConfig } from "../../extensions/modular/__generated__/ModularExtension/read/getExtensionConfig.js";
|
||||
export {
|
||||
installPublishedExtension,
|
||||
type InstallPublishedExtensionOptions,
|
||||
} from "../../extensions/modular/ModularCore/write/installPublishedExtension.js";
|
||||
export {
|
||||
uninstallPublishedExtension,
|
||||
type UninstallPublishedExtensionOptions,
|
||||
} from "../../extensions/modular/ModularCore/write/uninstallPublishedExtension.js";
|
||||
export {
|
||||
uninstallExtensionByProxy,
|
||||
type UninstallExtensionByProxyOptions,
|
||||
} from "../../extensions/modular/ModularCore/write/uninstallExtensionByProxy.js";
|
||||
Generated
+135
@@ -0,0 +1,135 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "getAccounts" function.
|
||||
*/
|
||||
export type GetAccountsParams = {
|
||||
start: AbiParameterToPrimitiveType<{ type: "uint256"; name: "start" }>;
|
||||
end: AbiParameterToPrimitiveType<{ type: "uint256"; name: "end" }>;
|
||||
};
|
||||
|
||||
export const FN_SELECTOR = "0xe68a7c3b" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
type: "uint256",
|
||||
name: "start",
|
||||
},
|
||||
{
|
||||
type: "uint256",
|
||||
name: "end",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
type: "address[]",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `getAccounts` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `getAccounts` method is supported.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isGetAccountsSupported } from "thirdweb/extensions/erc4337";
|
||||
*
|
||||
* const supported = await isGetAccountsSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isGetAccountsSupported(contract: ThirdwebContract<any>) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "getAccounts" function.
|
||||
* @param options - The options for the getAccounts function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeGetAccountsParams } "thirdweb/extensions/erc4337";
|
||||
* const result = encodeGetAccountsParams({
|
||||
* start: ...,
|
||||
* end: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeGetAccountsParams(options: GetAccountsParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.start, options.end]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "getAccounts" function into a Hex string with its parameters.
|
||||
* @param options - The options for the getAccounts function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeGetAccounts } "thirdweb/extensions/erc4337";
|
||||
* const result = encodeGetAccounts({
|
||||
* start: ...,
|
||||
* end: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeGetAccounts(options: GetAccountsParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeGetAccountsParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the getAccounts function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeGetAccountsResult } from "thirdweb/extensions/erc4337";
|
||||
* const result = decodeGetAccountsResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeGetAccountsResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "getAccounts" function on the contract.
|
||||
* @param options - The options for the getAccounts function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getAccounts } from "thirdweb/extensions/erc4337";
|
||||
*
|
||||
* const result = await getAccounts({
|
||||
* contract,
|
||||
* start: ...,
|
||||
* end: ...,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function getAccounts(
|
||||
options: BaseTransactionOptions<GetAccountsParams>,
|
||||
) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [options.start, options.end],
|
||||
});
|
||||
}
|
||||
Generated
+127
@@ -0,0 +1,127 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "isRegistered" function.
|
||||
*/
|
||||
export type IsRegisteredParams = {
|
||||
account: AbiParameterToPrimitiveType<{ type: "address"; name: "account" }>;
|
||||
};
|
||||
|
||||
export const FN_SELECTOR = "0xc3c5a547" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
type: "address",
|
||||
name: "account",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
type: "bool",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `isRegistered` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `isRegistered` method is supported.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isIsRegisteredSupported } from "thirdweb/extensions/erc4337";
|
||||
*
|
||||
* const supported = await isIsRegisteredSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isIsRegisteredSupported(contract: ThirdwebContract<any>) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "isRegistered" function.
|
||||
* @param options - The options for the isRegistered function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeIsRegisteredParams } "thirdweb/extensions/erc4337";
|
||||
* const result = encodeIsRegisteredParams({
|
||||
* account: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeIsRegisteredParams(options: IsRegisteredParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.account]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "isRegistered" function into a Hex string with its parameters.
|
||||
* @param options - The options for the isRegistered function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeIsRegistered } "thirdweb/extensions/erc4337";
|
||||
* const result = encodeIsRegistered({
|
||||
* account: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeIsRegistered(options: IsRegisteredParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeIsRegisteredParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the isRegistered function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeIsRegisteredResult } from "thirdweb/extensions/erc4337";
|
||||
* const result = decodeIsRegisteredResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeIsRegisteredResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "isRegistered" function on the contract.
|
||||
* @param options - The options for the isRegistered function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isRegistered } from "thirdweb/extensions/erc4337";
|
||||
*
|
||||
* const result = await isRegistered({
|
||||
* contract,
|
||||
* account: ...,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function isRegistered(
|
||||
options: BaseTransactionOptions<IsRegisteredParams>,
|
||||
) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [options.account],
|
||||
});
|
||||
}
|
||||
Generated
+74
@@ -0,0 +1,74 @@
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0x58451f97" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
type: "uint256",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `totalAccounts` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `totalAccounts` method is supported.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isTotalAccountsSupported } from "thirdweb/extensions/erc4337";
|
||||
*
|
||||
* const supported = await isTotalAccountsSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isTotalAccountsSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the totalAccounts function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeTotalAccountsResult } from "thirdweb/extensions/erc4337";
|
||||
* const result = decodeTotalAccountsResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeTotalAccountsResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "totalAccounts" function on the contract.
|
||||
* @param options - The options for the totalAccounts function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension ERC4337
|
||||
* @example
|
||||
* ```ts
|
||||
* import { totalAccounts } from "thirdweb/extensions/erc4337";
|
||||
*
|
||||
* const result = await totalAccounts({
|
||||
* contract,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function totalAccounts(options: BaseTransactionOptions) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [],
|
||||
});
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import type { Chain } from "../../../../chains/types.js";
|
||||
import type { ThirdwebClient } from "../../../../client/client.js";
|
||||
import type { ThirdwebContract } from "../../../../contract/contract.js";
|
||||
import { getOrDeployInfraForPublishedContract } from "../../../../contract/deployment/utils/bootstrap.js";
|
||||
import type { Account } from "../../../../wallets/interfaces/wallet.js";
|
||||
import { installExtension } from "../../__generated__/ModularCore/write/installExtension.js";
|
||||
|
||||
export type InstallPublishedExtensionOptions = {
|
||||
client: ThirdwebClient;
|
||||
chain: Chain;
|
||||
account: Account;
|
||||
contract: ThirdwebContract;
|
||||
extensionName: string;
|
||||
publisherAddress: string;
|
||||
version?: string;
|
||||
constructorParams?: unknown[];
|
||||
extensionData?: `0x${string}`;
|
||||
};
|
||||
|
||||
export function installPublishedExtension(
|
||||
options: InstallPublishedExtensionOptions,
|
||||
) {
|
||||
const {
|
||||
client,
|
||||
chain,
|
||||
account,
|
||||
contract,
|
||||
extensionName,
|
||||
constructorParams,
|
||||
publisherAddress,
|
||||
extensionData,
|
||||
} = options;
|
||||
|
||||
return installExtension({
|
||||
contract,
|
||||
asyncParams: async () => {
|
||||
const deployedExtension = await getOrDeployInfraForPublishedContract({
|
||||
chain,
|
||||
client,
|
||||
account,
|
||||
contractId: extensionName,
|
||||
constructorParams: constructorParams || [],
|
||||
publisher: publisherAddress,
|
||||
});
|
||||
return {
|
||||
extension: deployedExtension.implementationContract.address as string,
|
||||
data: extensionData || "0x",
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import type { Chain } from "../../../../chains/types.js";
|
||||
import type { ThirdwebClient } from "../../../../client/client.js";
|
||||
import {
|
||||
type ThirdwebContract,
|
||||
getContract,
|
||||
} from "../../../../contract/contract.js";
|
||||
import { resolveImplementation } from "../../../../utils/bytecode/resolveImplementation.js";
|
||||
import { uninstallExtension } from "../../__generated__/ModularCore/write/uninstallExtension.js";
|
||||
|
||||
export type UninstallExtensionByProxyOptions = {
|
||||
client: ThirdwebClient;
|
||||
chain: Chain;
|
||||
contract: ThirdwebContract;
|
||||
extensionProxyAddress: string;
|
||||
extensionData?: `0x${string}`;
|
||||
};
|
||||
|
||||
export function uninstallExtensionByProxy(
|
||||
options: UninstallExtensionByProxyOptions,
|
||||
) {
|
||||
const { client, chain, contract, extensionProxyAddress, extensionData } =
|
||||
options;
|
||||
|
||||
return uninstallExtension({
|
||||
contract,
|
||||
asyncParams: async () => {
|
||||
const extensionImplementation = await resolveImplementation(
|
||||
getContract({
|
||||
chain,
|
||||
client,
|
||||
address: extensionProxyAddress,
|
||||
}),
|
||||
);
|
||||
return {
|
||||
extension: extensionImplementation.address,
|
||||
data: extensionData || "0x",
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
import type { Chain } from "../../../../chains/types.js";
|
||||
import type { ThirdwebClient } from "../../../../client/client.js";
|
||||
import type { ThirdwebContract } from "../../../../contract/contract.js";
|
||||
import { getDeployedInfraContract } from "../../../../contract/deployment/utils/infra.js";
|
||||
import { uninstallExtension } from "../../__generated__/ModularCore/write/uninstallExtension.js";
|
||||
|
||||
export type UninstallPublishedExtensionOptions = {
|
||||
client: ThirdwebClient;
|
||||
chain: Chain;
|
||||
contract: ThirdwebContract;
|
||||
extensionName: string;
|
||||
publisherAddress: string;
|
||||
version?: string;
|
||||
constructorParams?: unknown[];
|
||||
extensionData?: `0x${string}`;
|
||||
};
|
||||
|
||||
export function uninstallPublishedExtension(
|
||||
options: UninstallPublishedExtensionOptions,
|
||||
) {
|
||||
const {
|
||||
client,
|
||||
chain,
|
||||
contract,
|
||||
extensionName,
|
||||
publisherAddress,
|
||||
constructorParams,
|
||||
extensionData,
|
||||
} = options;
|
||||
|
||||
return uninstallExtension({
|
||||
contract,
|
||||
asyncParams: async () => {
|
||||
const deployedExtension = await getDeployedInfraContract({
|
||||
chain,
|
||||
client,
|
||||
contractId: extensionName,
|
||||
constructorParams: constructorParams || [],
|
||||
publisher: publisherAddress,
|
||||
});
|
||||
return {
|
||||
extension: deployedExtension?.address as string,
|
||||
data: extensionData || "0x",
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
Generated
+134
@@ -0,0 +1,134 @@
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0x5357aa5e" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IModularCore.InstalledExtension[]",
|
||||
components: [
|
||||
{
|
||||
name: "implementation",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "config",
|
||||
type: "tuple",
|
||||
internalType: "struct IExtensionConfig.ExtensionConfig",
|
||||
components: [
|
||||
{
|
||||
name: "registerInstallationCallback",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
{
|
||||
name: "requiredInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "supportedInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "callbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.CallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "fallbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.FallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
{
|
||||
name: "permissionBits",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `getInstalledExtensions` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `getInstalledExtensions` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isGetInstalledExtensionsSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isGetInstalledExtensionsSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isGetInstalledExtensionsSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the getInstalledExtensions function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeGetInstalledExtensionsResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeGetInstalledExtensionsResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeGetInstalledExtensionsResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "getInstalledExtensions" function on the contract.
|
||||
* @param options - The options for the getInstalledExtensions function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getInstalledExtensions } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await getInstalledExtensions({
|
||||
* contract,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function getInstalledExtensions(options: BaseTransactionOptions) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [],
|
||||
});
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0xf147db8a" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IModularCore.SupportedCallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
{
|
||||
name: "mode",
|
||||
type: "uint8",
|
||||
internalType: "enum IModularCore.CallbackMode",
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `getSupportedCallbackFunctions` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `getSupportedCallbackFunctions` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isGetSupportedCallbackFunctionsSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isGetSupportedCallbackFunctionsSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isGetSupportedCallbackFunctionsSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the getSupportedCallbackFunctions function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeGetSupportedCallbackFunctionsResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeGetSupportedCallbackFunctionsResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeGetSupportedCallbackFunctionsResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "getSupportedCallbackFunctions" function on the contract.
|
||||
* @param options - The options for the getSupportedCallbackFunctions function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getSupportedCallbackFunctions } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await getSupportedCallbackFunctions({
|
||||
* contract,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function getSupportedCallbackFunctions(
|
||||
options: BaseTransactionOptions,
|
||||
) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [],
|
||||
});
|
||||
}
|
||||
Generated
+138
@@ -0,0 +1,138 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "supportsInterface" function.
|
||||
*/
|
||||
export type SupportsInterfaceParams = {
|
||||
interfaceID: AbiParameterToPrimitiveType<{
|
||||
name: "interfaceID";
|
||||
type: "bytes4";
|
||||
internalType: "bytes4";
|
||||
}>;
|
||||
};
|
||||
|
||||
export const FN_SELECTOR = "0x01ffc9a7" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "interfaceID",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `supportsInterface` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `supportsInterface` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isSupportsInterfaceSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isSupportsInterfaceSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isSupportsInterfaceSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "supportsInterface" function.
|
||||
* @param options - The options for the supportsInterface function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeSupportsInterfaceParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeSupportsInterfaceParams({
|
||||
* interfaceID: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeSupportsInterfaceParams(
|
||||
options: SupportsInterfaceParams,
|
||||
) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.interfaceID]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "supportsInterface" function into a Hex string with its parameters.
|
||||
* @param options - The options for the supportsInterface function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeSupportsInterface } "thirdweb/extensions/modular";
|
||||
* const result = encodeSupportsInterface({
|
||||
* interfaceID: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeSupportsInterface(options: SupportsInterfaceParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeSupportsInterfaceParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the supportsInterface function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeSupportsInterfaceResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeSupportsInterfaceResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeSupportsInterfaceResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "supportsInterface" function on the contract.
|
||||
* @param options - The options for the supportsInterface function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { supportsInterface } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await supportsInterface({
|
||||
* contract,
|
||||
* interfaceID: ...,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function supportsInterface(
|
||||
options: BaseTransactionOptions<SupportsInterfaceParams>,
|
||||
) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [options.interfaceID],
|
||||
});
|
||||
}
|
||||
Generated
+160
@@ -0,0 +1,160 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import type {
|
||||
BaseTransactionOptions,
|
||||
WithOverrides,
|
||||
} from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { once } from "../../../../../utils/promise/once.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "installExtension" function.
|
||||
*/
|
||||
export type InstallExtensionParams = WithOverrides<{
|
||||
extensionContract: AbiParameterToPrimitiveType<{
|
||||
name: "extensionContract";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
data: AbiParameterToPrimitiveType<{
|
||||
name: "data";
|
||||
type: "bytes";
|
||||
internalType: "bytes";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
export const FN_SELECTOR = "0xaca696f5" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "extensionContract",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "data",
|
||||
type: "bytes",
|
||||
internalType: "bytes",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `installExtension` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `installExtension` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isInstallExtensionSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isInstallExtensionSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isInstallExtensionSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "installExtension" function.
|
||||
* @param options - The options for the installExtension function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeInstallExtensionParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeInstallExtensionParams({
|
||||
* extensionContract: ...,
|
||||
* data: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeInstallExtensionParams(options: InstallExtensionParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [
|
||||
options.extensionContract,
|
||||
options.data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "installExtension" function into a Hex string with its parameters.
|
||||
* @param options - The options for the installExtension function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeInstallExtension } "thirdweb/extensions/modular";
|
||||
* const result = encodeInstallExtension({
|
||||
* extensionContract: ...,
|
||||
* data: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeInstallExtension(options: InstallExtensionParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeInstallExtensionParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "installExtension" function on the contract.
|
||||
* @param options - The options for the "installExtension" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { installExtension } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = installExtension({
|
||||
* contract,
|
||||
* extensionContract: ...,
|
||||
* data: ...,
|
||||
* overrides: {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function installExtension(
|
||||
options: BaseTransactionOptions<
|
||||
| InstallExtensionParams
|
||||
| {
|
||||
asyncParams: () => Promise<InstallExtensionParams>;
|
||||
}
|
||||
>,
|
||||
) {
|
||||
const asyncOptions = once(async () => {
|
||||
return "asyncParams" in options ? await options.asyncParams() : options;
|
||||
});
|
||||
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: async () => {
|
||||
const resolvedOptions = await asyncOptions();
|
||||
return [resolvedOptions.extensionContract, resolvedOptions.data] as const;
|
||||
},
|
||||
value: async () => (await asyncOptions()).overrides?.value,
|
||||
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
||||
gas: async () => (await asyncOptions()).overrides?.gas,
|
||||
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
||||
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: async () =>
|
||||
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
||||
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
||||
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
||||
});
|
||||
}
|
||||
Generated
+162
@@ -0,0 +1,162 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import type {
|
||||
BaseTransactionOptions,
|
||||
WithOverrides,
|
||||
} from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { once } from "../../../../../utils/promise/once.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "uninstallExtension" function.
|
||||
*/
|
||||
export type UninstallExtensionParams = WithOverrides<{
|
||||
extensionContract: AbiParameterToPrimitiveType<{
|
||||
name: "extensionContract";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
data: AbiParameterToPrimitiveType<{
|
||||
name: "data";
|
||||
type: "bytes";
|
||||
internalType: "bytes";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
export const FN_SELECTOR = "0x42b7d0c8" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "extensionContract",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "data",
|
||||
type: "bytes",
|
||||
internalType: "bytes",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `uninstallExtension` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `uninstallExtension` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isUninstallExtensionSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isUninstallExtensionSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isUninstallExtensionSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "uninstallExtension" function.
|
||||
* @param options - The options for the uninstallExtension function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeUninstallExtensionParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeUninstallExtensionParams({
|
||||
* extensionContract: ...,
|
||||
* data: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeUninstallExtensionParams(
|
||||
options: UninstallExtensionParams,
|
||||
) {
|
||||
return encodeAbiParameters(FN_INPUTS, [
|
||||
options.extensionContract,
|
||||
options.data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "uninstallExtension" function into a Hex string with its parameters.
|
||||
* @param options - The options for the uninstallExtension function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeUninstallExtension } "thirdweb/extensions/modular";
|
||||
* const result = encodeUninstallExtension({
|
||||
* extensionContract: ...,
|
||||
* data: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeUninstallExtension(options: UninstallExtensionParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeUninstallExtensionParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "uninstallExtension" function on the contract.
|
||||
* @param options - The options for the "uninstallExtension" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { uninstallExtension } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = uninstallExtension({
|
||||
* contract,
|
||||
* extensionContract: ...,
|
||||
* data: ...,
|
||||
* overrides: {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function uninstallExtension(
|
||||
options: BaseTransactionOptions<
|
||||
| UninstallExtensionParams
|
||||
| {
|
||||
asyncParams: () => Promise<UninstallExtensionParams>;
|
||||
}
|
||||
>,
|
||||
) {
|
||||
const asyncOptions = once(async () => {
|
||||
return "asyncParams" in options ? await options.asyncParams() : options;
|
||||
});
|
||||
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: async () => {
|
||||
const resolvedOptions = await asyncOptions();
|
||||
return [resolvedOptions.extensionContract, resolvedOptions.data] as const;
|
||||
},
|
||||
value: async () => (await asyncOptions()).overrides?.value,
|
||||
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
||||
gas: async () => (await asyncOptions()).overrides?.gas,
|
||||
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
||||
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: async () =>
|
||||
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
||||
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
||||
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
||||
});
|
||||
}
|
||||
Generated
+122
@@ -0,0 +1,122 @@
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0x7c173ecc" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "",
|
||||
type: "tuple",
|
||||
internalType: "struct IExtensionConfig.ExtensionConfig",
|
||||
components: [
|
||||
{
|
||||
name: "registerInstallationCallback",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
{
|
||||
name: "requiredInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "supportedInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "callbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.CallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "fallbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.FallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
{
|
||||
name: "permissionBits",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `getExtensionConfig` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `getExtensionConfig` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isGetExtensionConfigSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isGetExtensionConfigSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isGetExtensionConfigSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the getExtensionConfig function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeGetExtensionConfigResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeGetExtensionConfigResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeGetExtensionConfigResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "getExtensionConfig" function on the contract.
|
||||
* @param options - The options for the getExtensionConfig function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getExtensionConfig } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await getExtensionConfig({
|
||||
* contract,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function getExtensionConfig(options: BaseTransactionOptions) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [],
|
||||
});
|
||||
}
|
||||
Generated
+25
@@ -0,0 +1,25 @@
|
||||
import { prepareEvent } from "../../../../../event/prepare-event.js";
|
||||
|
||||
/**
|
||||
* Creates an event object for the ExtensionInstalled event.
|
||||
* @returns The prepared event object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getContractEvents } from "thirdweb";
|
||||
* import { extensionInstalledEvent } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const events = await getContractEvents({
|
||||
* contract,
|
||||
* events: [
|
||||
* extensionInstalledEvent()
|
||||
* ],
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function extensionInstalledEvent() {
|
||||
return prepareEvent({
|
||||
signature:
|
||||
"event ExtensionInstalled(address caller, address implementation, address installedExtension)",
|
||||
});
|
||||
}
|
||||
Generated
+25
@@ -0,0 +1,25 @@
|
||||
import { prepareEvent } from "../../../../../event/prepare-event.js";
|
||||
|
||||
/**
|
||||
* Creates an event object for the ExtensionUninstalled event.
|
||||
* @returns The prepared event object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getContractEvents } from "thirdweb";
|
||||
* import { extensionUninstalledEvent } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const events = await getContractEvents({
|
||||
* contract,
|
||||
* events: [
|
||||
* extensionUninstalledEvent()
|
||||
* ],
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function extensionUninstalledEvent() {
|
||||
return prepareEvent({
|
||||
signature:
|
||||
"event ExtensionUninstalled(address caller, address implementation, address installedExtension)",
|
||||
});
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { prepareEvent } from "../../../../../event/prepare-event.js";
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
|
||||
/**
|
||||
* Represents the filters for the "OwnershipHandoverCanceled" event.
|
||||
*/
|
||||
export type OwnershipHandoverCanceledEventFilters = Partial<{
|
||||
pendingOwner: AbiParameterToPrimitiveType<{
|
||||
name: "pendingOwner";
|
||||
type: "address";
|
||||
indexed: true;
|
||||
internalType: "address";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Creates an event object for the OwnershipHandoverCanceled event.
|
||||
* @param filters - Optional filters to apply to the event.
|
||||
* @returns The prepared event object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getContractEvents } from "thirdweb";
|
||||
* import { ownershipHandoverCanceledEvent } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const events = await getContractEvents({
|
||||
* contract,
|
||||
* events: [
|
||||
* ownershipHandoverCanceledEvent({
|
||||
* pendingOwner: ...,
|
||||
* })
|
||||
* ],
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function ownershipHandoverCanceledEvent(
|
||||
filters: OwnershipHandoverCanceledEventFilters = {},
|
||||
) {
|
||||
return prepareEvent({
|
||||
signature: "event OwnershipHandoverCanceled(address indexed pendingOwner)",
|
||||
filters,
|
||||
});
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { prepareEvent } from "../../../../../event/prepare-event.js";
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
|
||||
/**
|
||||
* Represents the filters for the "OwnershipHandoverRequested" event.
|
||||
*/
|
||||
export type OwnershipHandoverRequestedEventFilters = Partial<{
|
||||
pendingOwner: AbiParameterToPrimitiveType<{
|
||||
name: "pendingOwner";
|
||||
type: "address";
|
||||
indexed: true;
|
||||
internalType: "address";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Creates an event object for the OwnershipHandoverRequested event.
|
||||
* @param filters - Optional filters to apply to the event.
|
||||
* @returns The prepared event object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getContractEvents } from "thirdweb";
|
||||
* import { ownershipHandoverRequestedEvent } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const events = await getContractEvents({
|
||||
* contract,
|
||||
* events: [
|
||||
* ownershipHandoverRequestedEvent({
|
||||
* pendingOwner: ...,
|
||||
* })
|
||||
* ],
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function ownershipHandoverRequestedEvent(
|
||||
filters: OwnershipHandoverRequestedEventFilters = {},
|
||||
) {
|
||||
return prepareEvent({
|
||||
signature: "event OwnershipHandoverRequested(address indexed pendingOwner)",
|
||||
filters,
|
||||
});
|
||||
}
|
||||
Generated
+51
@@ -0,0 +1,51 @@
|
||||
import { prepareEvent } from "../../../../../event/prepare-event.js";
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
|
||||
/**
|
||||
* Represents the filters for the "OwnershipTransferred" event.
|
||||
*/
|
||||
export type OwnershipTransferredEventFilters = Partial<{
|
||||
oldOwner: AbiParameterToPrimitiveType<{
|
||||
name: "oldOwner";
|
||||
type: "address";
|
||||
indexed: true;
|
||||
internalType: "address";
|
||||
}>;
|
||||
newOwner: AbiParameterToPrimitiveType<{
|
||||
name: "newOwner";
|
||||
type: "address";
|
||||
indexed: true;
|
||||
internalType: "address";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Creates an event object for the OwnershipTransferred event.
|
||||
* @param filters - Optional filters to apply to the event.
|
||||
* @returns The prepared event object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getContractEvents } from "thirdweb";
|
||||
* import { ownershipTransferredEvent } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const events = await getContractEvents({
|
||||
* contract,
|
||||
* events: [
|
||||
* ownershipTransferredEvent({
|
||||
* oldOwner: ...,
|
||||
* newOwner: ...,
|
||||
* })
|
||||
* ],
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function ownershipTransferredEvent(
|
||||
filters: OwnershipTransferredEventFilters = {},
|
||||
) {
|
||||
return prepareEvent({
|
||||
signature:
|
||||
"event OwnershipTransferred(address indexed oldOwner, address indexed newOwner)",
|
||||
filters,
|
||||
});
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import { prepareEvent } from "../../../../../event/prepare-event.js";
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
|
||||
/**
|
||||
* Represents the filters for the "RolesUpdated" event.
|
||||
*/
|
||||
export type RolesUpdatedEventFilters = Partial<{
|
||||
user: AbiParameterToPrimitiveType<{
|
||||
name: "user";
|
||||
type: "address";
|
||||
indexed: true;
|
||||
internalType: "address";
|
||||
}>;
|
||||
roles: AbiParameterToPrimitiveType<{
|
||||
name: "roles";
|
||||
type: "uint256";
|
||||
indexed: true;
|
||||
internalType: "uint256";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Creates an event object for the RolesUpdated event.
|
||||
* @param filters - Optional filters to apply to the event.
|
||||
* @returns The prepared event object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getContractEvents } from "thirdweb";
|
||||
* import { rolesUpdatedEvent } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const events = await getContractEvents({
|
||||
* contract,
|
||||
* events: [
|
||||
* rolesUpdatedEvent({
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* })
|
||||
* ],
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function rolesUpdatedEvent(filters: RolesUpdatedEventFilters = {}) {
|
||||
return prepareEvent({
|
||||
signature:
|
||||
"event RolesUpdated(address indexed user, uint256 indexed roles)",
|
||||
filters,
|
||||
});
|
||||
}
|
||||
Generated
+134
@@ -0,0 +1,134 @@
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0x5357aa5e" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "_installedExtensions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IModularCore.InstalledExtension[]",
|
||||
components: [
|
||||
{
|
||||
name: "implementation",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "config",
|
||||
type: "tuple",
|
||||
internalType: "struct IExtensionConfig.ExtensionConfig",
|
||||
components: [
|
||||
{
|
||||
name: "registerInstallationCallback",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
{
|
||||
name: "requiredInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "supportedInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "callbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.CallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "fallbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.FallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
{
|
||||
name: "permissionBits",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `getInstalledExtensions` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `getInstalledExtensions` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isGetInstalledExtensionsSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isGetInstalledExtensionsSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isGetInstalledExtensionsSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the getInstalledExtensions function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeGetInstalledExtensionsResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeGetInstalledExtensionsResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeGetInstalledExtensionsResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "getInstalledExtensions" function on the contract.
|
||||
* @param options - The options for the getInstalledExtensions function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getInstalledExtensions } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await getInstalledExtensions({
|
||||
* contract,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function getInstalledExtensions(options: BaseTransactionOptions) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [],
|
||||
});
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0xf147db8a" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IModularCore.SupportedCallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
{
|
||||
name: "mode",
|
||||
type: "uint8",
|
||||
internalType: "enum IModularCore.CallbackMode",
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `getSupportedCallbackFunctions` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `getSupportedCallbackFunctions` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isGetSupportedCallbackFunctionsSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isGetSupportedCallbackFunctionsSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isGetSupportedCallbackFunctionsSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the getSupportedCallbackFunctions function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeGetSupportedCallbackFunctionsResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeGetSupportedCallbackFunctionsResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeGetSupportedCallbackFunctionsResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "getSupportedCallbackFunctions" function on the contract.
|
||||
* @param options - The options for the getSupportedCallbackFunctions function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getSupportedCallbackFunctions } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await getSupportedCallbackFunctions({
|
||||
* contract,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function getSupportedCallbackFunctions(
|
||||
options: BaseTransactionOptions,
|
||||
) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [],
|
||||
});
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "hasAllRoles" function.
|
||||
*/
|
||||
export type HasAllRolesParams = {
|
||||
user: AbiParameterToPrimitiveType<{
|
||||
name: "user";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
roles: AbiParameterToPrimitiveType<{
|
||||
name: "roles";
|
||||
type: "uint256";
|
||||
internalType: "uint256";
|
||||
}>;
|
||||
};
|
||||
|
||||
export const FN_SELECTOR = "0x1cd64df4" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "user",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "roles",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `hasAllRoles` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `hasAllRoles` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isHasAllRolesSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isHasAllRolesSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isHasAllRolesSupported(contract: ThirdwebContract<any>) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "hasAllRoles" function.
|
||||
* @param options - The options for the hasAllRoles function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeHasAllRolesParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeHasAllRolesParams({
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeHasAllRolesParams(options: HasAllRolesParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.user, options.roles]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "hasAllRoles" function into a Hex string with its parameters.
|
||||
* @param options - The options for the hasAllRoles function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeHasAllRoles } "thirdweb/extensions/modular";
|
||||
* const result = encodeHasAllRoles({
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeHasAllRoles(options: HasAllRolesParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeHasAllRolesParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the hasAllRoles function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeHasAllRolesResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeHasAllRolesResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeHasAllRolesResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "hasAllRoles" function on the contract.
|
||||
* @param options - The options for the hasAllRoles function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { hasAllRoles } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await hasAllRoles({
|
||||
* contract,
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function hasAllRoles(
|
||||
options: BaseTransactionOptions<HasAllRolesParams>,
|
||||
) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [options.user, options.roles],
|
||||
});
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "hasAnyRole" function.
|
||||
*/
|
||||
export type HasAnyRoleParams = {
|
||||
user: AbiParameterToPrimitiveType<{
|
||||
name: "user";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
roles: AbiParameterToPrimitiveType<{
|
||||
name: "roles";
|
||||
type: "uint256";
|
||||
internalType: "uint256";
|
||||
}>;
|
||||
};
|
||||
|
||||
export const FN_SELECTOR = "0x514e62fc" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "user",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "roles",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `hasAnyRole` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `hasAnyRole` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isHasAnyRoleSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isHasAnyRoleSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isHasAnyRoleSupported(contract: ThirdwebContract<any>) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "hasAnyRole" function.
|
||||
* @param options - The options for the hasAnyRole function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeHasAnyRoleParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeHasAnyRoleParams({
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeHasAnyRoleParams(options: HasAnyRoleParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.user, options.roles]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "hasAnyRole" function into a Hex string with its parameters.
|
||||
* @param options - The options for the hasAnyRole function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeHasAnyRole } "thirdweb/extensions/modular";
|
||||
* const result = encodeHasAnyRole({
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeHasAnyRole(options: HasAnyRoleParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeHasAnyRoleParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the hasAnyRole function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeHasAnyRoleResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeHasAnyRoleResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeHasAnyRoleResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "hasAnyRole" function on the contract.
|
||||
* @param options - The options for the hasAnyRole function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { hasAnyRole } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await hasAnyRole({
|
||||
* contract,
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function hasAnyRole(
|
||||
options: BaseTransactionOptions<HasAnyRoleParams>,
|
||||
) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [options.user, options.roles],
|
||||
});
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0x8da5cb5b" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "result",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `owner` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `owner` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isOwnerSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isOwnerSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isOwnerSupported(contract: ThirdwebContract<any>) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the owner function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeOwnerResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeOwnerResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeOwnerResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "owner" function on the contract.
|
||||
* @param options - The options for the owner function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { owner } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await owner({
|
||||
* contract,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function owner(options: BaseTransactionOptions) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [],
|
||||
});
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "ownershipHandoverExpiresAt" function.
|
||||
*/
|
||||
export type OwnershipHandoverExpiresAtParams = {
|
||||
pendingOwner: AbiParameterToPrimitiveType<{
|
||||
name: "pendingOwner";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
};
|
||||
|
||||
export const FN_SELECTOR = "0xfee81cf4" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "pendingOwner",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "result",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `ownershipHandoverExpiresAt` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `ownershipHandoverExpiresAt` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isOwnershipHandoverExpiresAtSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isOwnershipHandoverExpiresAtSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isOwnershipHandoverExpiresAtSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "ownershipHandoverExpiresAt" function.
|
||||
* @param options - The options for the ownershipHandoverExpiresAt function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeOwnershipHandoverExpiresAtParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeOwnershipHandoverExpiresAtParams({
|
||||
* pendingOwner: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeOwnershipHandoverExpiresAtParams(
|
||||
options: OwnershipHandoverExpiresAtParams,
|
||||
) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.pendingOwner]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "ownershipHandoverExpiresAt" function into a Hex string with its parameters.
|
||||
* @param options - The options for the ownershipHandoverExpiresAt function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeOwnershipHandoverExpiresAt } "thirdweb/extensions/modular";
|
||||
* const result = encodeOwnershipHandoverExpiresAt({
|
||||
* pendingOwner: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeOwnershipHandoverExpiresAt(
|
||||
options: OwnershipHandoverExpiresAtParams,
|
||||
) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeOwnershipHandoverExpiresAtParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the ownershipHandoverExpiresAt function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeOwnershipHandoverExpiresAtResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeOwnershipHandoverExpiresAtResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeOwnershipHandoverExpiresAtResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "ownershipHandoverExpiresAt" function on the contract.
|
||||
* @param options - The options for the ownershipHandoverExpiresAt function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { ownershipHandoverExpiresAt } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await ownershipHandoverExpiresAt({
|
||||
* contract,
|
||||
* pendingOwner: ...,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function ownershipHandoverExpiresAt(
|
||||
options: BaseTransactionOptions<OwnershipHandoverExpiresAtParams>,
|
||||
) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [options.pendingOwner],
|
||||
});
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "rolesOf" function.
|
||||
*/
|
||||
export type RolesOfParams = {
|
||||
user: AbiParameterToPrimitiveType<{
|
||||
name: "user";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
};
|
||||
|
||||
export const FN_SELECTOR = "0x2de94807" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "user",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "roles",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `rolesOf` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `rolesOf` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isRolesOfSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isRolesOfSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isRolesOfSupported(contract: ThirdwebContract<any>) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "rolesOf" function.
|
||||
* @param options - The options for the rolesOf function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeRolesOfParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeRolesOfParams({
|
||||
* user: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeRolesOfParams(options: RolesOfParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.user]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "rolesOf" function into a Hex string with its parameters.
|
||||
* @param options - The options for the rolesOf function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeRolesOf } "thirdweb/extensions/modular";
|
||||
* const result = encodeRolesOf({
|
||||
* user: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeRolesOf(options: RolesOfParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeRolesOfParams(options).slice(2)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the rolesOf function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeRolesOfResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeRolesOfResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeRolesOfResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "rolesOf" function on the contract.
|
||||
* @param options - The options for the rolesOf function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { rolesOf } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await rolesOf({
|
||||
* contract,
|
||||
* user: ...,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function rolesOf(options: BaseTransactionOptions<RolesOfParams>) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [options.user],
|
||||
});
|
||||
}
|
||||
Generated
+138
@@ -0,0 +1,138 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "supportsInterface" function.
|
||||
*/
|
||||
export type SupportsInterfaceParams = {
|
||||
interfaceId: AbiParameterToPrimitiveType<{
|
||||
name: "interfaceId";
|
||||
type: "bytes4";
|
||||
internalType: "bytes4";
|
||||
}>;
|
||||
};
|
||||
|
||||
export const FN_SELECTOR = "0x01ffc9a7" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "interfaceId",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `supportsInterface` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `supportsInterface` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isSupportsInterfaceSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isSupportsInterfaceSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isSupportsInterfaceSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "supportsInterface" function.
|
||||
* @param options - The options for the supportsInterface function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeSupportsInterfaceParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeSupportsInterfaceParams({
|
||||
* interfaceId: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeSupportsInterfaceParams(
|
||||
options: SupportsInterfaceParams,
|
||||
) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.interfaceId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "supportsInterface" function into a Hex string with its parameters.
|
||||
* @param options - The options for the supportsInterface function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeSupportsInterface } "thirdweb/extensions/modular";
|
||||
* const result = encodeSupportsInterface({
|
||||
* interfaceId: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeSupportsInterface(options: SupportsInterfaceParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeSupportsInterfaceParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the supportsInterface function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeSupportsInterfaceResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeSupportsInterfaceResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeSupportsInterfaceResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "supportsInterface" function on the contract.
|
||||
* @param options - The options for the supportsInterface function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { supportsInterface } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await supportsInterface({
|
||||
* contract,
|
||||
* interfaceId: ...,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function supportsInterface(
|
||||
options: BaseTransactionOptions<SupportsInterfaceParams>,
|
||||
) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [options.interfaceId],
|
||||
});
|
||||
}
|
||||
Generated
+53
@@ -0,0 +1,53 @@
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0x54d1f13d" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `cancelOwnershipHandover` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `cancelOwnershipHandover` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isCancelOwnershipHandoverSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isCancelOwnershipHandoverSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isCancelOwnershipHandoverSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "cancelOwnershipHandover" function on the contract.
|
||||
* @param options - The options for the "cancelOwnershipHandover" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { cancelOwnershipHandover } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = cancelOwnershipHandover();
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function cancelOwnershipHandover(options: BaseTransactionOptions) {
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import type {
|
||||
BaseTransactionOptions,
|
||||
WithOverrides,
|
||||
} from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { once } from "../../../../../utils/promise/once.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "completeOwnershipHandover" function.
|
||||
*/
|
||||
export type CompleteOwnershipHandoverParams = WithOverrides<{
|
||||
pendingOwner: AbiParameterToPrimitiveType<{
|
||||
name: "pendingOwner";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
export const FN_SELECTOR = "0xf04e283e" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "pendingOwner",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `completeOwnershipHandover` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `completeOwnershipHandover` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isCompleteOwnershipHandoverSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isCompleteOwnershipHandoverSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isCompleteOwnershipHandoverSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "completeOwnershipHandover" function.
|
||||
* @param options - The options for the completeOwnershipHandover function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeCompleteOwnershipHandoverParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeCompleteOwnershipHandoverParams({
|
||||
* pendingOwner: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeCompleteOwnershipHandoverParams(
|
||||
options: CompleteOwnershipHandoverParams,
|
||||
) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.pendingOwner]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "completeOwnershipHandover" function into a Hex string with its parameters.
|
||||
* @param options - The options for the completeOwnershipHandover function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeCompleteOwnershipHandover } "thirdweb/extensions/modular";
|
||||
* const result = encodeCompleteOwnershipHandover({
|
||||
* pendingOwner: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeCompleteOwnershipHandover(
|
||||
options: CompleteOwnershipHandoverParams,
|
||||
) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeCompleteOwnershipHandoverParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "completeOwnershipHandover" function on the contract.
|
||||
* @param options - The options for the "completeOwnershipHandover" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { completeOwnershipHandover } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = completeOwnershipHandover({
|
||||
* contract,
|
||||
* pendingOwner: ...,
|
||||
* overrides: {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function completeOwnershipHandover(
|
||||
options: BaseTransactionOptions<
|
||||
| CompleteOwnershipHandoverParams
|
||||
| {
|
||||
asyncParams: () => Promise<CompleteOwnershipHandoverParams>;
|
||||
}
|
||||
>,
|
||||
) {
|
||||
const asyncOptions = once(async () => {
|
||||
return "asyncParams" in options ? await options.asyncParams() : options;
|
||||
});
|
||||
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: async () => {
|
||||
const resolvedOptions = await asyncOptions();
|
||||
return [resolvedOptions.pendingOwner] as const;
|
||||
},
|
||||
value: async () => (await asyncOptions()).overrides?.value,
|
||||
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
||||
gas: async () => (await asyncOptions()).overrides?.gas,
|
||||
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
||||
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: async () =>
|
||||
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
||||
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
||||
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
||||
});
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import type {
|
||||
BaseTransactionOptions,
|
||||
WithOverrides,
|
||||
} from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { once } from "../../../../../utils/promise/once.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "grantRoles" function.
|
||||
*/
|
||||
export type GrantRolesParams = WithOverrides<{
|
||||
user: AbiParameterToPrimitiveType<{
|
||||
name: "user";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
roles: AbiParameterToPrimitiveType<{
|
||||
name: "roles";
|
||||
type: "uint256";
|
||||
internalType: "uint256";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
export const FN_SELECTOR = "0x1c10893f" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "user",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "roles",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `grantRoles` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `grantRoles` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isGrantRolesSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isGrantRolesSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isGrantRolesSupported(contract: ThirdwebContract<any>) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "grantRoles" function.
|
||||
* @param options - The options for the grantRoles function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeGrantRolesParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeGrantRolesParams({
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeGrantRolesParams(options: GrantRolesParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.user, options.roles]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "grantRoles" function into a Hex string with its parameters.
|
||||
* @param options - The options for the grantRoles function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeGrantRoles } "thirdweb/extensions/modular";
|
||||
* const result = encodeGrantRoles({
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeGrantRoles(options: GrantRolesParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeGrantRolesParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "grantRoles" function on the contract.
|
||||
* @param options - The options for the "grantRoles" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { grantRoles } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = grantRoles({
|
||||
* contract,
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* overrides: {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function grantRoles(
|
||||
options: BaseTransactionOptions<
|
||||
| GrantRolesParams
|
||||
| {
|
||||
asyncParams: () => Promise<GrantRolesParams>;
|
||||
}
|
||||
>,
|
||||
) {
|
||||
const asyncOptions = once(async () => {
|
||||
return "asyncParams" in options ? await options.asyncParams() : options;
|
||||
});
|
||||
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: async () => {
|
||||
const resolvedOptions = await asyncOptions();
|
||||
return [resolvedOptions.user, resolvedOptions.roles] as const;
|
||||
},
|
||||
value: async () => (await asyncOptions()).overrides?.value,
|
||||
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
||||
gas: async () => (await asyncOptions()).overrides?.gas,
|
||||
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
||||
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: async () =>
|
||||
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
||||
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
||||
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
||||
});
|
||||
}
|
||||
Generated
+157
@@ -0,0 +1,157 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import type {
|
||||
BaseTransactionOptions,
|
||||
WithOverrides,
|
||||
} from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { once } from "../../../../../utils/promise/once.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "installExtension" function.
|
||||
*/
|
||||
export type InstallExtensionParams = WithOverrides<{
|
||||
extension: AbiParameterToPrimitiveType<{
|
||||
name: "_extension";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
data: AbiParameterToPrimitiveType<{
|
||||
name: "_data";
|
||||
type: "bytes";
|
||||
internalType: "bytes";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
export const FN_SELECTOR = "0xaca696f5" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "_extension",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "_data",
|
||||
type: "bytes",
|
||||
internalType: "bytes",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `installExtension` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `installExtension` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isInstallExtensionSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isInstallExtensionSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isInstallExtensionSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "installExtension" function.
|
||||
* @param options - The options for the installExtension function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeInstallExtensionParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeInstallExtensionParams({
|
||||
* extension: ...,
|
||||
* data: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeInstallExtensionParams(options: InstallExtensionParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.extension, options.data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "installExtension" function into a Hex string with its parameters.
|
||||
* @param options - The options for the installExtension function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeInstallExtension } "thirdweb/extensions/modular";
|
||||
* const result = encodeInstallExtension({
|
||||
* extension: ...,
|
||||
* data: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeInstallExtension(options: InstallExtensionParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeInstallExtensionParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "installExtension" function on the contract.
|
||||
* @param options - The options for the "installExtension" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { installExtension } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = installExtension({
|
||||
* contract,
|
||||
* extension: ...,
|
||||
* data: ...,
|
||||
* overrides: {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function installExtension(
|
||||
options: BaseTransactionOptions<
|
||||
| InstallExtensionParams
|
||||
| {
|
||||
asyncParams: () => Promise<InstallExtensionParams>;
|
||||
}
|
||||
>,
|
||||
) {
|
||||
const asyncOptions = once(async () => {
|
||||
return "asyncParams" in options ? await options.asyncParams() : options;
|
||||
});
|
||||
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: async () => {
|
||||
const resolvedOptions = await asyncOptions();
|
||||
return [resolvedOptions.extension, resolvedOptions.data] as const;
|
||||
},
|
||||
value: async () => (await asyncOptions()).overrides?.value,
|
||||
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
||||
gas: async () => (await asyncOptions()).overrides?.gas,
|
||||
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
||||
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: async () =>
|
||||
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
||||
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
||||
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
||||
});
|
||||
}
|
||||
Generated
+53
@@ -0,0 +1,53 @@
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0x715018a6" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `renounceOwnership` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `renounceOwnership` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isRenounceOwnershipSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isRenounceOwnershipSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isRenounceOwnershipSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "renounceOwnership" function on the contract.
|
||||
* @param options - The options for the "renounceOwnership" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { renounceOwnership } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = renounceOwnership();
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function renounceOwnership(options: BaseTransactionOptions) {
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import type {
|
||||
BaseTransactionOptions,
|
||||
WithOverrides,
|
||||
} from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { once } from "../../../../../utils/promise/once.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "renounceRoles" function.
|
||||
*/
|
||||
export type RenounceRolesParams = WithOverrides<{
|
||||
roles: AbiParameterToPrimitiveType<{
|
||||
name: "roles";
|
||||
type: "uint256";
|
||||
internalType: "uint256";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
export const FN_SELECTOR = "0x183a4f6e" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "roles",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `renounceRoles` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `renounceRoles` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isRenounceRolesSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isRenounceRolesSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isRenounceRolesSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "renounceRoles" function.
|
||||
* @param options - The options for the renounceRoles function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeRenounceRolesParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeRenounceRolesParams({
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeRenounceRolesParams(options: RenounceRolesParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.roles]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "renounceRoles" function into a Hex string with its parameters.
|
||||
* @param options - The options for the renounceRoles function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeRenounceRoles } "thirdweb/extensions/modular";
|
||||
* const result = encodeRenounceRoles({
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeRenounceRoles(options: RenounceRolesParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeRenounceRolesParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "renounceRoles" function on the contract.
|
||||
* @param options - The options for the "renounceRoles" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { renounceRoles } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = renounceRoles({
|
||||
* contract,
|
||||
* roles: ...,
|
||||
* overrides: {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function renounceRoles(
|
||||
options: BaseTransactionOptions<
|
||||
| RenounceRolesParams
|
||||
| {
|
||||
asyncParams: () => Promise<RenounceRolesParams>;
|
||||
}
|
||||
>,
|
||||
) {
|
||||
const asyncOptions = once(async () => {
|
||||
return "asyncParams" in options ? await options.asyncParams() : options;
|
||||
});
|
||||
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: async () => {
|
||||
const resolvedOptions = await asyncOptions();
|
||||
return [resolvedOptions.roles] as const;
|
||||
},
|
||||
value: async () => (await asyncOptions()).overrides?.value,
|
||||
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
||||
gas: async () => (await asyncOptions()).overrides?.gas,
|
||||
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
||||
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: async () =>
|
||||
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
||||
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
||||
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
||||
});
|
||||
}
|
||||
packages/thirdweb/src/extensions/modular/__generated__/ModularCore/write/requestOwnershipHandover.ts
Generated
+53
@@ -0,0 +1,53 @@
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0x25692962" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `requestOwnershipHandover` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `requestOwnershipHandover` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isRequestOwnershipHandoverSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isRequestOwnershipHandoverSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isRequestOwnershipHandoverSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "requestOwnershipHandover" function on the contract.
|
||||
* @param options - The options for the "requestOwnershipHandover" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { requestOwnershipHandover } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = requestOwnershipHandover();
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function requestOwnershipHandover(options: BaseTransactionOptions) {
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import type {
|
||||
BaseTransactionOptions,
|
||||
WithOverrides,
|
||||
} from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { once } from "../../../../../utils/promise/once.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "revokeRoles" function.
|
||||
*/
|
||||
export type RevokeRolesParams = WithOverrides<{
|
||||
user: AbiParameterToPrimitiveType<{
|
||||
name: "user";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
roles: AbiParameterToPrimitiveType<{
|
||||
name: "roles";
|
||||
type: "uint256";
|
||||
internalType: "uint256";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
export const FN_SELECTOR = "0x4a4ee7b1" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "user",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "roles",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `revokeRoles` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `revokeRoles` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isRevokeRolesSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isRevokeRolesSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isRevokeRolesSupported(contract: ThirdwebContract<any>) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "revokeRoles" function.
|
||||
* @param options - The options for the revokeRoles function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeRevokeRolesParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeRevokeRolesParams({
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeRevokeRolesParams(options: RevokeRolesParams) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.user, options.roles]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "revokeRoles" function into a Hex string with its parameters.
|
||||
* @param options - The options for the revokeRoles function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeRevokeRoles } "thirdweb/extensions/modular";
|
||||
* const result = encodeRevokeRoles({
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeRevokeRoles(options: RevokeRolesParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeRevokeRolesParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "revokeRoles" function on the contract.
|
||||
* @param options - The options for the "revokeRoles" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { revokeRoles } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = revokeRoles({
|
||||
* contract,
|
||||
* user: ...,
|
||||
* roles: ...,
|
||||
* overrides: {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function revokeRoles(
|
||||
options: BaseTransactionOptions<
|
||||
| RevokeRolesParams
|
||||
| {
|
||||
asyncParams: () => Promise<RevokeRolesParams>;
|
||||
}
|
||||
>,
|
||||
) {
|
||||
const asyncOptions = once(async () => {
|
||||
return "asyncParams" in options ? await options.asyncParams() : options;
|
||||
});
|
||||
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: async () => {
|
||||
const resolvedOptions = await asyncOptions();
|
||||
return [resolvedOptions.user, resolvedOptions.roles] as const;
|
||||
},
|
||||
value: async () => (await asyncOptions()).overrides?.value,
|
||||
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
||||
gas: async () => (await asyncOptions()).overrides?.gas,
|
||||
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
||||
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: async () =>
|
||||
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
||||
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
||||
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
||||
});
|
||||
}
|
||||
Generated
+146
@@ -0,0 +1,146 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import type {
|
||||
BaseTransactionOptions,
|
||||
WithOverrides,
|
||||
} from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { once } from "../../../../../utils/promise/once.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "transferOwnership" function.
|
||||
*/
|
||||
export type TransferOwnershipParams = WithOverrides<{
|
||||
newOwner: AbiParameterToPrimitiveType<{
|
||||
name: "newOwner";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
export const FN_SELECTOR = "0xf2fde38b" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `transferOwnership` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `transferOwnership` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isTransferOwnershipSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isTransferOwnershipSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isTransferOwnershipSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "transferOwnership" function.
|
||||
* @param options - The options for the transferOwnership function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeTransferOwnershipParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeTransferOwnershipParams({
|
||||
* newOwner: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeTransferOwnershipParams(
|
||||
options: TransferOwnershipParams,
|
||||
) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.newOwner]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "transferOwnership" function into a Hex string with its parameters.
|
||||
* @param options - The options for the transferOwnership function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeTransferOwnership } "thirdweb/extensions/modular";
|
||||
* const result = encodeTransferOwnership({
|
||||
* newOwner: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeTransferOwnership(options: TransferOwnershipParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeTransferOwnershipParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "transferOwnership" function on the contract.
|
||||
* @param options - The options for the "transferOwnership" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { transferOwnership } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = transferOwnership({
|
||||
* contract,
|
||||
* newOwner: ...,
|
||||
* overrides: {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function transferOwnership(
|
||||
options: BaseTransactionOptions<
|
||||
| TransferOwnershipParams
|
||||
| {
|
||||
asyncParams: () => Promise<TransferOwnershipParams>;
|
||||
}
|
||||
>,
|
||||
) {
|
||||
const asyncOptions = once(async () => {
|
||||
return "asyncParams" in options ? await options.asyncParams() : options;
|
||||
});
|
||||
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: async () => {
|
||||
const resolvedOptions = await asyncOptions();
|
||||
return [resolvedOptions.newOwner] as const;
|
||||
},
|
||||
value: async () => (await asyncOptions()).overrides?.value,
|
||||
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
||||
gas: async () => (await asyncOptions()).overrides?.gas,
|
||||
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
||||
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: async () =>
|
||||
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
||||
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
||||
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
||||
});
|
||||
}
|
||||
Generated
+159
@@ -0,0 +1,159 @@
|
||||
import type { AbiParameterToPrimitiveType } from "abitype";
|
||||
import type {
|
||||
BaseTransactionOptions,
|
||||
WithOverrides,
|
||||
} from "../../../../../transaction/types.js";
|
||||
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
||||
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
||||
import { once } from "../../../../../utils/promise/once.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
/**
|
||||
* Represents the parameters for the "uninstallExtension" function.
|
||||
*/
|
||||
export type UninstallExtensionParams = WithOverrides<{
|
||||
extension: AbiParameterToPrimitiveType<{
|
||||
name: "_extension";
|
||||
type: "address";
|
||||
internalType: "address";
|
||||
}>;
|
||||
data: AbiParameterToPrimitiveType<{
|
||||
name: "_data";
|
||||
type: "bytes";
|
||||
internalType: "bytes";
|
||||
}>;
|
||||
}>;
|
||||
|
||||
export const FN_SELECTOR = "0x42b7d0c8" as const;
|
||||
const FN_INPUTS = [
|
||||
{
|
||||
name: "_extension",
|
||||
type: "address",
|
||||
internalType: "address",
|
||||
},
|
||||
{
|
||||
name: "_data",
|
||||
type: "bytes",
|
||||
internalType: "bytes",
|
||||
},
|
||||
] as const;
|
||||
const FN_OUTPUTS = [] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `uninstallExtension` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `uninstallExtension` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isUninstallExtensionSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isUninstallExtensionSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isUninstallExtensionSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the parameters for the "uninstallExtension" function.
|
||||
* @param options - The options for the uninstallExtension function.
|
||||
* @returns The encoded ABI parameters.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeUninstallExtensionParams } "thirdweb/extensions/modular";
|
||||
* const result = encodeUninstallExtensionParams({
|
||||
* extension: ...,
|
||||
* data: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeUninstallExtensionParams(
|
||||
options: UninstallExtensionParams,
|
||||
) {
|
||||
return encodeAbiParameters(FN_INPUTS, [options.extension, options.data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the "uninstallExtension" function into a Hex string with its parameters.
|
||||
* @param options - The options for the uninstallExtension function.
|
||||
* @returns The encoded hexadecimal string.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { encodeUninstallExtension } "thirdweb/extensions/modular";
|
||||
* const result = encodeUninstallExtension({
|
||||
* extension: ...,
|
||||
* data: ...,
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
export function encodeUninstallExtension(options: UninstallExtensionParams) {
|
||||
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
||||
// we can do this because we know the specific formats of the values
|
||||
return (FN_SELECTOR +
|
||||
encodeUninstallExtensionParams(options).slice(
|
||||
2,
|
||||
)) as `${typeof FN_SELECTOR}${string}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a transaction to call the "uninstallExtension" function on the contract.
|
||||
* @param options - The options for the "uninstallExtension" function.
|
||||
* @returns A prepared transaction object.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { uninstallExtension } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const transaction = uninstallExtension({
|
||||
* contract,
|
||||
* extension: ...,
|
||||
* data: ...,
|
||||
* overrides: {
|
||||
* ...
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // Send the transaction
|
||||
* ...
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export function uninstallExtension(
|
||||
options: BaseTransactionOptions<
|
||||
| UninstallExtensionParams
|
||||
| {
|
||||
asyncParams: () => Promise<UninstallExtensionParams>;
|
||||
}
|
||||
>,
|
||||
) {
|
||||
const asyncOptions = once(async () => {
|
||||
return "asyncParams" in options ? await options.asyncParams() : options;
|
||||
});
|
||||
|
||||
return prepareContractCall({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: async () => {
|
||||
const resolvedOptions = await asyncOptions();
|
||||
return [resolvedOptions.extension, resolvedOptions.data] as const;
|
||||
},
|
||||
value: async () => (await asyncOptions()).overrides?.value,
|
||||
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
||||
gas: async () => (await asyncOptions()).overrides?.gas,
|
||||
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
||||
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
||||
maxPriorityFeePerGas: async () =>
|
||||
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
||||
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
||||
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
||||
});
|
||||
}
|
||||
Generated
+122
@@ -0,0 +1,122 @@
|
||||
import { readContract } from "../../../../../transaction/read-contract.js";
|
||||
import type { BaseTransactionOptions } from "../../../../../transaction/types.js";
|
||||
|
||||
import { decodeAbiParameters } from "viem";
|
||||
import type { Hex } from "../../../../../utils/encoding/hex.js";
|
||||
import type { ThirdwebContract } from "../../../../../contract/contract.js";
|
||||
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
||||
|
||||
export const FN_SELECTOR = "0x7c173ecc" as const;
|
||||
const FN_INPUTS = [] as const;
|
||||
const FN_OUTPUTS = [
|
||||
{
|
||||
name: "",
|
||||
type: "tuple",
|
||||
internalType: "struct IExtensionConfig.ExtensionConfig",
|
||||
components: [
|
||||
{
|
||||
name: "registerInstallationCallback",
|
||||
type: "bool",
|
||||
internalType: "bool",
|
||||
},
|
||||
{
|
||||
name: "requiredInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "supportedInterfaces",
|
||||
type: "bytes4[]",
|
||||
internalType: "bytes4[]",
|
||||
},
|
||||
{
|
||||
name: "callbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.CallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "fallbackFunctions",
|
||||
type: "tuple[]",
|
||||
internalType: "struct IExtensionConfig.FallbackFunction[]",
|
||||
components: [
|
||||
{
|
||||
name: "selector",
|
||||
type: "bytes4",
|
||||
internalType: "bytes4",
|
||||
},
|
||||
{
|
||||
name: "permissionBits",
|
||||
type: "uint256",
|
||||
internalType: "uint256",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Checks if the `getExtensionConfig` method is supported by the given contract.
|
||||
* @param contract The ThirdwebContract.
|
||||
* @returns A promise that resolves to a boolean indicating if the `getExtensionConfig` method is supported.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { isGetExtensionConfigSupported } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const supported = await isGetExtensionConfigSupported(contract);
|
||||
* ```
|
||||
*/
|
||||
export async function isGetExtensionConfigSupported(
|
||||
contract: ThirdwebContract<any>,
|
||||
) {
|
||||
return detectMethod({
|
||||
contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the result of the getExtensionConfig function call.
|
||||
* @param result - The hexadecimal result to decode.
|
||||
* @returns The decoded result as per the FN_OUTPUTS definition.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { decodeGetExtensionConfigResult } from "thirdweb/extensions/modular";
|
||||
* const result = decodeGetExtensionConfigResult("...");
|
||||
* ```
|
||||
*/
|
||||
export function decodeGetExtensionConfigResult(result: Hex) {
|
||||
return decodeAbiParameters(FN_OUTPUTS, result)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the "getExtensionConfig" function on the contract.
|
||||
* @param options - The options for the getExtensionConfig function.
|
||||
* @returns The parsed result of the function call.
|
||||
* @extension MODULAR
|
||||
* @example
|
||||
* ```ts
|
||||
* import { getExtensionConfig } from "thirdweb/extensions/modular";
|
||||
*
|
||||
* const result = await getExtensionConfig({
|
||||
* contract,
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
export async function getExtensionConfig(options: BaseTransactionOptions) {
|
||||
return readContract({
|
||||
contract: options.contract,
|
||||
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
||||
params: [],
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ANVIL_CHAIN } from "../../../test/src/chains.js";
|
||||
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
||||
import { TEST_ACCOUNT_A } from "../../../test/src/test-wallets.js";
|
||||
import { ADDRESS_ZERO } from "../../constants/addresses.js";
|
||||
import { getContract } from "../../contract/contract.js";
|
||||
import { sendTransaction } from "../../transaction/actions/send-transaction.js";
|
||||
import { installPublishedExtension } from "../modular/ModularCore/write/installPublishedExtension.js";
|
||||
import { uninstallExtensionByProxy } from "../modular/ModularCore/write/uninstallExtensionByProxy.js";
|
||||
import { uninstallPublishedExtension } from "../modular/ModularCore/write/uninstallPublishedExtension.js";
|
||||
import { getInstalledExtensions } from "../modular/__generated__/ModularCore/read/getInstalledExtensions.js";
|
||||
import { deployPublishedContract } from "./deploy-published.js";
|
||||
|
||||
describe.runIf(process.env.TW_SECRET_KEY)(
|
||||
"deployModularCore",
|
||||
{
|
||||
timeout: 120000,
|
||||
},
|
||||
() => {
|
||||
it("should deploy a published autofactory modular core contract", async () => {
|
||||
const address = await deployPublishedContract({
|
||||
client: TEST_CLIENT,
|
||||
chain: ANVIL_CHAIN,
|
||||
account: TEST_ACCOUNT_A,
|
||||
contractId: "DemoCore",
|
||||
contractParams: [TEST_ACCOUNT_A.address, [], ["0x"]],
|
||||
publisher: "0xFD78F7E2dF2B8c3D5bff0413c96f3237500898B3",
|
||||
});
|
||||
expect(address).toBeDefined();
|
||||
expect(address.length).toBe(42);
|
||||
|
||||
const installedExtensions = await getInstalledExtensions({
|
||||
contract: getContract({
|
||||
client: TEST_CLIENT,
|
||||
chain: ANVIL_CHAIN,
|
||||
address,
|
||||
}),
|
||||
});
|
||||
expect(installedExtensions.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should install and uninstall an extension by proxy address", async () => {
|
||||
// deploy core contract with extension
|
||||
const address = await deployPublishedContract({
|
||||
client: TEST_CLIENT,
|
||||
chain: ANVIL_CHAIN,
|
||||
account: TEST_ACCOUNT_A,
|
||||
contractId: "DemoCore",
|
||||
contractParams: [TEST_ACCOUNT_A.address, [], ["0x"]],
|
||||
publisher: "0xFD78F7E2dF2B8c3D5bff0413c96f3237500898B3",
|
||||
});
|
||||
|
||||
const core = getContract({
|
||||
client: TEST_CLIENT,
|
||||
chain: ANVIL_CHAIN,
|
||||
address,
|
||||
});
|
||||
|
||||
// install extension with published name
|
||||
const installTransaction = installPublishedExtension({
|
||||
contract: core,
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
account: TEST_ACCOUNT_A,
|
||||
extensionName: "DemoExtensionWithFunctions",
|
||||
publisherAddress: "0xFD78F7E2dF2B8c3D5bff0413c96f3237500898B3",
|
||||
});
|
||||
await sendTransaction({
|
||||
transaction: installTransaction,
|
||||
account: TEST_ACCOUNT_A,
|
||||
});
|
||||
|
||||
// get installed extension proxy address
|
||||
let installedExtensions = await getInstalledExtensions({
|
||||
contract: core,
|
||||
});
|
||||
const extensionAddress = installedExtensions[0]?.implementation;
|
||||
expect(extensionAddress).to.not.equal(ADDRESS_ZERO);
|
||||
|
||||
// uninstall extension
|
||||
const uninstallTransaction = uninstallExtensionByProxy({
|
||||
contract: core,
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
extensionProxyAddress: extensionAddress as string,
|
||||
extensionData: "0x",
|
||||
});
|
||||
await sendTransaction({
|
||||
transaction: uninstallTransaction,
|
||||
account: TEST_ACCOUNT_A,
|
||||
});
|
||||
|
||||
installedExtensions = await getInstalledExtensions({
|
||||
contract: core,
|
||||
});
|
||||
|
||||
expect(installedExtensions.length).toBe(0);
|
||||
});
|
||||
|
||||
it("should install and uninstall extensions by publish name", async () => {
|
||||
// deploy core contract with extension
|
||||
const address = await deployPublishedContract({
|
||||
client: TEST_CLIENT,
|
||||
chain: ANVIL_CHAIN,
|
||||
account: TEST_ACCOUNT_A,
|
||||
contractId: "DemoCore",
|
||||
contractParams: [TEST_ACCOUNT_A.address, [], ["0x"]],
|
||||
publisher: "0xFD78F7E2dF2B8c3D5bff0413c96f3237500898B3",
|
||||
});
|
||||
|
||||
const core = getContract({
|
||||
client: TEST_CLIENT,
|
||||
chain: ANVIL_CHAIN,
|
||||
address,
|
||||
});
|
||||
|
||||
// install extension with published name
|
||||
const installTransaction = installPublishedExtension({
|
||||
contract: core,
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
account: TEST_ACCOUNT_A,
|
||||
extensionName: "DemoExtensionWithFunctions",
|
||||
publisherAddress: "0xFD78F7E2dF2B8c3D5bff0413c96f3237500898B3",
|
||||
});
|
||||
await sendTransaction({
|
||||
transaction: installTransaction,
|
||||
account: TEST_ACCOUNT_A,
|
||||
});
|
||||
|
||||
let installedExtensions = await getInstalledExtensions({
|
||||
contract: core,
|
||||
});
|
||||
|
||||
expect(installedExtensions.length).toBe(1);
|
||||
|
||||
// uninstall extension
|
||||
const uninstallTransaction = uninstallPublishedExtension({
|
||||
contract: core,
|
||||
chain: ANVIL_CHAIN,
|
||||
client: TEST_CLIENT,
|
||||
extensionName: "DemoExtensionWithFunctions",
|
||||
publisherAddress: "0xFD78F7E2dF2B8c3D5bff0413c96f3237500898B3",
|
||||
extensionData: "0x",
|
||||
});
|
||||
await sendTransaction({
|
||||
transaction: uninstallTransaction,
|
||||
account: TEST_ACCOUNT_A,
|
||||
});
|
||||
|
||||
installedExtensions = await getInstalledExtensions({
|
||||
contract: core,
|
||||
});
|
||||
|
||||
expect(installedExtensions.length).toBe(0);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -180,11 +180,14 @@ export type ExtendedMetadata = {
|
||||
params: Array<{ name: string; type: string }>;
|
||||
customFactoryAddresses: Record<string, string>;
|
||||
};
|
||||
modularFactoryInput?: {
|
||||
hooksParamName: string;
|
||||
};
|
||||
factoryAddresses?: Record<string, string>;
|
||||
}
|
||||
| undefined;
|
||||
deployType?: "standard" | "autoFactory" | "customFactory";
|
||||
routerType?: "none" | "plugin" | "dynamic";
|
||||
routerType?: "none" | "plugin" | "dynamic" | "modular";
|
||||
networksForDeployment?: {
|
||||
allNetworks?: boolean;
|
||||
networksEnabled?: number[];
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Reference in New Issue
Block a user