Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7524d7a
wip
ciaranightingale Jul 5, 2023
de65f04
merge main
ciaranightingale Jul 5, 2023
98c7018
wip
ciaranightingale Jul 12, 2023
820d4cc
Merge branch 'main' into ciara/tba
ciaranightingale Jul 12, 2023
4755ac0
merge main
ciaranightingale Jul 24, 2023
2580d13
wip
ciaranightingale Jul 24, 2023
279b260
update with clientId & secretKey & requested changes
ciaranightingale Jul 24, 2023
c8445b9
Merge branch 'ciara/tba' of https://github.com/thirdweb-dev/js into c…
ciaranightingale Jul 24, 2023
af57f47
Merge branch 'main' into ciara/tba
ciaranightingale Jul 24, 2023
2db5249
fix build
ciaranightingale Jul 24, 2023
73a51fa
wip
ciaranightingale Jul 26, 2023
39e22b9
wip
ciaranightingale Jul 26, 2023
f34654b
Merge branch 'ciara/tba' of https://github.com/thirdweb-dev/js into c…
ciaranightingale Jul 26, 2023
7477b73
restructure
Jul 26, 2023
5ab826b
cleanup
joaquim-verges Jul 27, 2023
909ca2f
Merge branch 'main' into ciara/tba
joaquim-verges Jul 27, 2023
0c9ada2
Merge branch 'main' into ciara/tba
ciaranightingale Jul 27, 2023
cf5bb93
working code & fix factoryAddress required
ciaranightingale Jul 27, 2023
fdee3f5
Merge branch 'main' into ciara/tba
joaquim-verges Aug 9, 2023
0bdddc0
Merge branch 'main' into ciara/tba
joaquim-verges Aug 9, 2023
f11c12a
Merge branch 'main' into ciara/tba
joaquim-verges Oct 13, 2023
e93da7f
fix types
joaquim-verges Oct 14, 2023
6b4642a
linting
joaquim-verges Oct 14, 2023
8a07db2
fix build
joaquim-verges Oct 14, 2023
a8464f6
Merge branch 'main' into ciara/tba
joaquim-verges Oct 24, 2023
4c8dd1c
require account impl for now
joaquim-verges Oct 24, 2023
c9616ed
changeset
joaquim-verges Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/chains/chains/2358.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
"faucets": [],
"infoURL": "https://kroma.network",
"icon": {
"url": "ipfs://QmcYafk2je5rMqgnFPDZJTaLi6dgFgq96vmX2Li6DX441B",
"url": "ipfs://QmVpV2WET6ZrqnvvPfE9hCwoE2y5ygbPuniuugpaRoxrho",
"width": 320,
"height": 320,
"format": "svg"
Expand All @@ -28,7 +28,7 @@ export default {
"name": "blockscout",
"url": "https://blockscout.sepolia.kroma.network",
"icon": {
"url": "ipfs://QmcYafk2je5rMqgnFPDZJTaLi6dgFgq96vmX2Li6DX441B",
"url": "ipfs://QmVpV2WET6ZrqnvvPfE9hCwoE2y5ygbPuniuugpaRoxrho",
"width": 320,
"height": 320,
"format": "svg"
Expand Down
35 changes: 35 additions & 0 deletions packages/chains/chains/411.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Chain } from "../src/types";
export default {
"name": "Pepe Chain Mainnet",
"chain": "PC",
"status": "active",
"icon": {
"url": "ipfs://bafkreibjsc3gww3moti27za2hpyq552aevux3yv5y2ntdklksyr4v4uavy",
"width": 512,
"height": 512,
"format": "png"
},
"rpc": [
"https://pepe-chain.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.pepe-chain.vip"
],
"faucets": [],
"nativeCurrency": {
"name": "Pepe",
"symbol": "PEPE",
"decimals": 18
},
"infoURL": "https://pepe-chain.vip",
"shortName": "pepe",
"chainId": 411,
"networkId": 411,
"explorers": [
{
"name": "pepechain explorer",
"url": "https://explorer.pepe-chain.vip",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "pepe-chain"
} as const satisfies Chain;
37 changes: 37 additions & 0 deletions packages/chains/chains/42888.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { Chain } from "../src/types";
export default {
"name": "Kinto Testnet",
"title": "Kinto Testnet",
"chain": "ETH",
"rpc": [
"https://kinto-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"http://35.215.120.180:8545"
],
"features": [
{
"name": "EIP155"
},
{
"name": "EIP1559"
}
],
"faucets": [],
"nativeCurrency": {
"name": "Ether",
"symbol": "ETH",
"decimals": 18
},
"infoURL": "https://ethereum.org",
"shortName": "keth",
"chainId": 42888,
"networkId": 42888,
"explorers": [
{
"name": "kintoscan",
"url": "http://35.215.120.180:4000",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "kinto-testnet"
} as const satisfies Chain;
6 changes: 6 additions & 0 deletions packages/chains/chains/534849.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import type { Chain } from "../src/types";
export default {
"name": "Shinarium Beta",
"chain": "Shinarium",
"icon": {
"url": "ipfs://bafybeiadbavrwcial76vs5ovhyykyaobteltuhliqcthdairbja4klwzhu",
"width": 1000,
"height": 1000,
"format": "png"
},
"rpc": [
"https://shinarium-beta.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.shinarium.org"
Expand Down
15 changes: 13 additions & 2 deletions packages/chains/chains/59140.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
"rpc": [
"https://linea-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://linea-goerli.infura.io/v3/${INFURA_API_KEY}",
"wss://linea-goerli.infura.io/v3/${INFURA_API_KEY}",
"wss://linea-goerli.infura.io/ws/v3/${INFURA_API_KEY}",
"https://rpc.goerli.linea.build",
"wss://rpc.goerli.linea.build"
],
Expand Down Expand Up @@ -39,7 +39,18 @@ export default {
},
"explorers": [
{
"name": "blockscout",
"name": "Etherscan",
"url": "https://goerli.lineascan.build",
"standard": "EIP3091",
"icon": {
"url": "ipfs://QmURjritnHL7a8TwZgsFwp3f272DJmG5paaPtWDZ98QZwH",
"width": 97,
"height": 102,
"format": "svg"
}
},
{
"name": "Blockscout",
"url": "https://explorer.goerli.linea.build",
"standard": "EIP3091",
"icon": {
Expand Down
36 changes: 36 additions & 0 deletions packages/chains/chains/990.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { Chain } from "../src/types";
export default {
"name": "eLiberty Mainnet",
"chain": "$EL",
"icon": {
"url": "ipfs://Qmcr8US1DZcK3ooiMtE8tEQPgep12abXzxPw1jCkgZhji9",
"width": 150,
"height": 150,
"format": "png"
},
"rpc": [
"https://eliberty.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.eliberty.ngo"
],
"faucets": [
"https://faucet.eliberty.ngo"
],
"nativeCurrency": {
"name": "eLiberty",
"symbol": "$EL",
"decimals": 18
},
"infoURL": "https://eliberty.ngo",
"shortName": "ELm",
"chainId": 990,
"networkId": 990,
"explorers": [
{
"name": "eLiberty Mainnet",
"url": "https://explorer.eliberty.ngo",
"standard": "EIP3091"
}
],
"testnet": false,
"slug": "eliberty"
} as const satisfies Chain;
36 changes: 36 additions & 0 deletions packages/chains/chains/99099.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { Chain } from "../src/types";
export default {
"name": "eLiberty Testnet",
"chain": "$EL",
"icon": {
"url": "ipfs://Qmcr8US1DZcK3ooiMtE8tEQPgep12abXzxPw1jCkgZhji9",
"width": 150,
"height": 150,
"format": "png"
},
"rpc": [
"https://eliberty-testnet.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://testnet-rpc.eliberty.ngo"
],
"faucets": [
"https://faucet.eliberty.ngo"
],
"nativeCurrency": {
"name": "eLiberty",
"symbol": "$EL",
"decimals": 18
},
"infoURL": "https://eliberty.ngo",
"shortName": "ELt",
"chainId": 99099,
"networkId": 99099,
"explorers": [
{
"name": "eLiberty Testnet",
"url": "https://testnet.eliberty.ngo",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "eliberty-testnet"
} as const satisfies Chain;
2 changes: 1 addition & 1 deletion packages/sdk/src/evm/core/classes/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class Account<TContract extends IAccountCore>
validityEndTimestamp: BigNumber.from(
Math.floor(
new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 10).getTime() /
1000,
1000,
),
),
uid: resolveOrGenerateId(undefined),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"main": "dist/thirdweb-dev-wallets-evm-connectors-token-bound-smart-wallet.cjs.js",
"module": "dist/thirdweb-dev-wallets-evm-connectors-token-bound-smart-wallet.esm.js",
"browser": {
"./dist/thirdweb-dev-wallets-evm-connectors-token-bound-smart-wallet.esm.js": "./dist/thirdweb-dev-wallets-evm-connectors-token-bound-smart-wallet.browser.esm.js"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"main": "dist/thirdweb-dev-wallets-evm-wallets-token-bound-smart-wallet.cjs.js",
"module": "dist/thirdweb-dev-wallets-evm-wallets-token-bound-smart-wallet.esm.js",
"browser": {
"./dist/thirdweb-dev-wallets-evm-wallets-token-bound-smart-wallet.esm.js": "./dist/thirdweb-dev-wallets-evm-wallets-token-bound-smart-wallet.browser.esm.js"
}
}
14 changes: 14 additions & 0 deletions packages/wallets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,27 @@
},
"default": "./evm/connectors/coinbase-wallet/dist/thirdweb-dev-wallets-evm-connectors-coinbase-wallet.cjs.js"
},
"./evm/wallets/token-bound-smart-wallet": {
"module": {
"browser": "./evm/wallets/token-bound-smart-wallet/dist/thirdweb-dev-wallets-evm-wallets-token-bound-smart-wallet.browser.esm.js",
"default": "./evm/wallets/token-bound-smart-wallet/dist/thirdweb-dev-wallets-evm-wallets-token-bound-smart-wallet.esm.js"
},
"default": "./evm/wallets/token-bound-smart-wallet/dist/thirdweb-dev-wallets-evm-wallets-token-bound-smart-wallet.cjs.js"
},
"./evm/connectors/wallet-connect-v1": {
"module": {
"browser": "./evm/connectors/wallet-connect-v1/dist/thirdweb-dev-wallets-evm-connectors-wallet-connect-v1.browser.esm.js",
"default": "./evm/connectors/wallet-connect-v1/dist/thirdweb-dev-wallets-evm-connectors-wallet-connect-v1.esm.js"
},
"default": "./evm/connectors/wallet-connect-v1/dist/thirdweb-dev-wallets-evm-connectors-wallet-connect-v1.cjs.js"
},
"./evm/connectors/token-bound-smart-wallet": {
"module": {
"browser": "./evm/connectors/token-bound-smart-wallet/dist/thirdweb-dev-wallets-evm-connectors-token-bound-smart-wallet.browser.esm.js",
"default": "./evm/connectors/token-bound-smart-wallet/dist/thirdweb-dev-wallets-evm-connectors-token-bound-smart-wallet.esm.js"
},
"default": "./evm/connectors/token-bound-smart-wallet/dist/thirdweb-dev-wallets-evm-connectors-token-bound-smart-wallet.cjs.js"
},
"./package.json": "./package.json"
},
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/wallets",
Expand Down
37 changes: 32 additions & 5 deletions packages/wallets/src/evm/connectors/smart-wallet/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Chain, getChainByChainId } from "@thirdweb-dev/chains";
import { Chain, getChainByChainId, getChainBySlug } from "@thirdweb-dev/chains";
import { ConnectParams, Connector } from "../../interfaces/connector";
import { ERC4337EthersProvider } from "./lib/erc4337-provider";
import { getVerifyingPaymaster } from "./lib/paymaster";
Expand All @@ -24,10 +24,11 @@ import {
import { AccountAPI } from "./lib/account";

export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
private config: SmartWalletConfig;
protected config: SmartWalletConfig;
private aaProvider: ERC4337EthersProvider | undefined;
private accountApi: AccountAPI | undefined;
personalWallet?: EVMWallet;
chainId?: number;

constructor(config: SmartWalletConfig) {
super();
Expand All @@ -41,6 +42,7 @@ export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
secretKey: config.secretKey,
}) as providers.BaseProvider;
const chainSlug = await this.getChainSlug(config.chain, originalProvider);
this.chainId = await this.getChainId(config.chain, originalProvider);
const bundlerUrl =
this.config.bundlerUrl || `https://${chainSlug}.bundler.thirdweb.com`;
const paymasterUrl =
Expand Down Expand Up @@ -218,9 +220,9 @@ export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
return await this.accountApi.isAcountDeployed();
}

private defaultFactoryInfo(): FactoryContractInfo {
protected defaultFactoryInfo(): FactoryContractInfo {
return {
createAccount: async (factory: SmartContract, owner: string) => {
createAccount: async (factory, owner) => {
return factory.prepare("createAccount", [
owner,
ethers.utils.toUtf8Bytes(""),
Expand All @@ -241,7 +243,7 @@ export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
};
}

private defaultAccountInfo(): AccountContractInfo {
protected defaultAccountInfo(): AccountContractInfo {
return {
execute: async (account, target, value, data) => {
return account.prepare("execute", [target, value, data]);
Expand Down Expand Up @@ -276,4 +278,29 @@ export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
throw new Error(`Invalid network: ${chainOrRpc}`);
}
}

protected async getChainId(
chainOrRpc: ChainOrRpcUrl,
provider: ethers.providers.Provider,
): Promise<number> {
if (typeof chainOrRpc === "object") {
return chainOrRpc.chainId;
}
if (typeof chainOrRpc === "number") {
const chain = getChainByChainId(chainOrRpc);
return chain.chainId;
}
if (typeof chainOrRpc === "string") {
if (chainOrRpc.startsWith("http") || chainOrRpc.startsWith("ws")) {
// if it's a url, try to get the chain id from the provider
const chainId = (await provider.getNetwork()).chainId;
const chain = getChainByChainId(chainId);
return chain.chainId;
}
// otherwise its the network name
return getChainBySlug(chainOrRpc).chainId;
} else {
throw new Error(`Invalid network: ${chainOrRpc}`);
}
}
}
5 changes: 3 additions & 2 deletions packages/wallets/src/evm/connectors/smart-wallet/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type SmartWalletOptions = WalletOptions<{}>;

export interface AccountApiParams
extends Omit<BaseApiParams, "provider">,
ContractInfo {
ContractInfo {
chain: ChainOrRpcUrl;
localSigner: Signer;
factoryAddress: string;
Expand Down Expand Up @@ -82,6 +82,7 @@ export type FactoryContractInfo = {
createAccount: (
factory: SmartContract,
owner: string,
optionalParam?: any
) => Promise<Transaction>;
getAccountAddress: (factory: SmartContract, owner: string) => Promise<string>;
getAccountAddress: (factory: SmartContract, owner: string, optionalParam?: any) => Promise<string>;
};
Loading