Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
working code & fix factoryAddress required
  • Loading branch information
ciaranightingale committed Jul 27, 2023
commit cf5bb9382a548c196826b23ebafba812de6bcf0e
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
import { TokenBoundSmartWalletConfig } from "./types";
import { TokenBoundSmartWalletConfig, TokenBoundSmartWalletConfigInput } from "./types";
import { ethers } from "ethers";
import { SmartWalletConnector } from "../smart-wallet";
import {
AccountContractInfo,
FactoryContractInfo,
AccountContractInfo,
FactoryContractInfo,
} from "../smart-wallet/types";
import { ERC6551_REGISTRY } from "../smart-wallet/lib/constants";
import { SmartWalletConfig } from "../smart-wallet/types";

export class TokenBoundSmartWalletConnector extends SmartWalletConnector {
protected config: TokenBoundSmartWalletConfig;
protected config: TokenBoundSmartWalletConfig;

constructor(config: TokenBoundSmartWalletConfig) {
config.factoryAddress = config.factoryAddress || ERC6551_REGISTRY;
constructor(input: TokenBoundSmartWalletConfigInput) {
input.factoryAddress = input.factoryAddress || ERC6551_REGISTRY;
super(input as TokenBoundSmartWalletConfig);
this.config = input as TokenBoundSmartWalletConfig;
}

super(config);
this.config = config;
}
protected defaultAccountInfo(): AccountContractInfo {
return {
execute: async (account, target, value, data) => {
return account.prepare("executeCall", [target, value, data]);
},
getNonce: async (account) => {
return account.call("nonce", []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumb question but in the parent SmartWallet class, the calls here are: execute and getNonce, just making sure these are different on purpose

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah in the official registry, the function signatures are different - they are of this format

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you double check that these can be configured back if they so choose

@joaquim-verges could you check this please - my assumption was to use the erc-6551 registry function signatures by default rather than the ones we have - is this the route we are choosing to go? SHould we have a custom option or something which uses the thirdweb defaults? I just wanted to keep things simple but I'm not sure

},
};
}

protected defaultAccountInfo(): AccountContractInfo {
return {
execute: async (account, target, value, data) => {
return account.prepare("executeCall", [target, value, data]);
},
getNonce: async (account) => {
return account.call("nonce", []);
},
};
}

protected defaultFactoryInfo(): FactoryContractInfo {
return {
createAccount: async (factory, owner) => {
return factory.prepare("createAccount", [
this.config.accountImplementation,
this.chainId,
this.config.tokenContract,
this.config.tokenId,
this.config.salt,
ethers.utils.toUtf8Bytes(""),
]);
},
getAccountAddress: async (factory, owner) => {
return await factory.call("address", [
this.config.accountImplementation,
this.chainId,
this.config.tokenContract,
this.config.tokenId,
this.config.salt,
]);
},
};
}
protected defaultFactoryInfo(): FactoryContractInfo {
return {
createAccount: async (factory, owner) => {
return factory.prepare("createAccount", [
this.config.accountImplementation,
this.chainId,
this.config.tokenContract,
this.config.tokenId,
this.config.salt,
ethers.utils.toUtf8Bytes(""),
]);
},
getAccountAddress: async (factory, owner) => {
return await factory.call("account", [
this.config.accountImplementation,
this.chainId,
this.config.tokenContract,
this.config.tokenId,
this.config.salt,
]);
},
};
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
import type { BigNumberish } from "ethers";
import { WalletConnectReceiverConfig } from "../../../core/types/walletConnect";
import type { ChainOrRpcUrl } from "@thirdweb-dev/sdk";
import { ContractInfoInput } from "../smart-wallet/types";
import { PaymasterAPI } from "@account-abstraction/sdk";
import { SmartWalletConfig } from "../smart-wallet/types";

export type TokenBoundSmartWalletConfigInput = {
chain: ChainOrRpcUrl;
factoryAddress?: string;
clientId?: string;
secretKey?: string;
gasless: boolean;
bundlerUrl?: string;
paymasterUrl?: string;
paymasterAPI?: PaymasterAPI;
entryPointAddress?: string;
tokenContract: string;
tokenId: BigNumberish;
accountImplementation: string; // TODO provide default implementation published by us
salt?: BigNumberish;
} & ContractInfoInput &
WalletConnectReceiverConfig;

export type TokenBoundSmartWalletConfig = {
tokenContract: string;
tokenId: BigNumberish;
accountImplementation: string; // TODO provide default implementation published by us
salt?: BigNumberish;
tokenContract: string;
tokenId: BigNumberish;
accountImplementation: string; // TODO provide default implementation published by us
salt?: BigNumberish;
} & SmartWalletConfig;
56 changes: 28 additions & 28 deletions packages/wallets/src/evm/wallets/token-bound-smart-wallet.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import { SmartWallet } from "./smart-wallet";
import type { TokenBoundSmartWalletConnector as TokenBoundSmartWalletConnectorType } from "../connectors/token-bound-smart-wallet";
import { walletIds } from "../constants/walletIds";
import type { TokenBoundSmartWalletConfig } from "../connectors/token-bound-smart-wallet/types";
import type { TokenBoundSmartWalletConfigInput, TokenBoundSmartWalletConfig } from "../connectors/token-bound-smart-wallet/types";
import { WalletOptions } from "./base";

/**
*
*/
export class TokenBoundSmartWallet extends SmartWallet {
connector?: TokenBoundSmartWalletConnectorType;
connector?: TokenBoundSmartWalletConnectorType;

static meta = {
name: "Token Bound Smart Wallet",
iconURL:
"ipfs://QmeAJVqn17aDNQhjEU3kcWVZCFBrfta8LzaDGkS8Egdiyk/token-bound-smart-wallet.svg",
};
static meta = {
name: "Token Bound Smart Wallet",
iconURL:
"ipfs://QmeAJVqn17aDNQhjEU3kcWVZCFBrfta8LzaDGkS8Egdiyk/token-bound-smart-wallet.svg",
};

static id = walletIds.tokenBoundSmartWallet;
public get walletName() {
return "Token Bound Smart Wallet";
}
static id = walletIds.tokenBoundSmartWallet;
public get walletName() {
return "Token Bound Smart Wallet";
}

constructor(options: WalletOptions<TokenBoundSmartWalletConfig>) {
super(options);
}
constructor(options: WalletOptions<TokenBoundSmartWalletConfigInput>) {
super(options as TokenBoundSmartWalletConfig);
}

async getConnector(): Promise<TokenBoundSmartWalletConnectorType> {
if (!this.connector) {
if (this.enableConnectApp) {
await this.wcWallet.init();
this.setupWalletConnectEventsListeners();
}
async getConnector(): Promise<TokenBoundSmartWalletConnectorType> {
if (!this.connector) {
if (this.enableConnectApp) {
await this.wcWallet.init();
this.setupWalletConnectEventsListeners();
}

const { TokenBoundSmartWalletConnector } = await import(
"../connectors/token-bound-smart-wallet"
);
this.connector = new TokenBoundSmartWalletConnector(
this.options as TokenBoundSmartWalletConfig,
);
const { TokenBoundSmartWalletConnector } = await import(
"../connectors/token-bound-smart-wallet"
);
this.connector = new TokenBoundSmartWalletConnector(
this.options as TokenBoundSmartWalletConfig,
);
}
return this.connector;
}
return this.connector;
}
}