Add celo demo script (#9)
-
celo testnet
-
update SDKs
-
celo script
diff --git a/index.ts b/index.ts
index 0c70db3..5a992de 100644
--- a/index.ts
+++ b/index.ts
@@ -1,14 +1,10 @@
import { config } from "dotenv";
import { ThirdwebSDK } from "@thirdweb-dev/sdk";
-import {
- getAllSmartWallets,
- isSmartWalletDeployed,
- SmartWallet,
- SmartWalletConfig,
-} from "@thirdweb-dev/wallets";
+import { SmartWallet, SmartWalletConfig } from "@thirdweb-dev/wallets";
import { LocalWalletNode } from "@thirdweb-dev/wallets/evm/wallets/local-wallet-node";
import {
BaseGoerli,
+ CeloAlfajoresTestnet,
Goerli,
Mumbai,
OptimismGoerli,
@@ -17,6 +13,7 @@ import {
} from "@thirdweb-dev/chains";
import {
batchTransaction,
+ claimCeloToken,
claimERC721Token,
claimMumbaiNFT,
claimSepoliaNFT,
@@ -27,7 +24,7 @@ import {
config();
// Put your chain here
-const chain = Mumbai;
+const chain = CeloAlfajoresTestnet;
// Put your thirdweb API key here (or in .env)
const thirdwebApiKey = process.env.THIRDWEB_API_KEY as string;
@@ -39,6 +36,7 @@ const factories = {
[ScrollAlphaTestnet.chainId]: "0x2eaDAa60dBB74Ead3E20b23E4C5A0Dd789932846",
[Mumbai.chainId]: "0x272A90FF4403473d766127A3CCB7ff1d9E7d45A2",
[Sepolia.chainId]: "0x9D4409c65AC036860F5CAAF34D5b69ae324A7075",
+ [CeloAlfajoresTestnet.chainId]: "0xE646849d679602F2588CA8eEDf0b261B1aB085AF",
};
const main = async () => {
@@ -64,30 +62,19 @@ const main = async () => {
thirdwebApiKey,
};
- const accounts = await getAllSmartWallets(
- chain,
- factoryAddress,
- personalWalletAddress
- );
- console.log(`Found accounts for local signer`, accounts);
-
- const isWalletDeployed = await isSmartWalletDeployed(
- chain,
- factoryAddress,
- personalWalletAddress
- );
- console.log(`Is smart wallet deployed?`, isWalletDeployed);
-
// connect the smart wallet
const smartWallet = new SmartWallet(config);
await smartWallet.connect({
personalWallet: localWallet,
});
+ const isWalletDeployed = await smartWallet.isDeployed();
+ console.log(`Is smart wallet deployed?`, isWalletDeployed);
+
// now use the SDK normally
const sdk = await ThirdwebSDK.fromWallet(smartWallet, chain);
console.log("Smart Account addr:", await sdk.wallet.getAddress());
- console.log("balance:", (await sdk.wallet.balance()).displayValue);
+ console.log("native balance:", (await sdk.wallet.balance()).displayValue);
console.log("Executing contract call via SDK...");
switch (chain.chainId as number) {
@@ -107,6 +94,9 @@ const main = async () => {
case Sepolia.chainId:
await claimSepoliaNFT(sdk);
break;
+ case CeloAlfajoresTestnet.chainId:
+ await claimCeloToken(sdk);
+ break;
}
} catch (e) {
console.error("Something went wrong: ", await e);
diff --git a/package.json b/package.json
index 93763b8..e2ae309 100644
--- a/package.json
+++ b/package.json
@@ -12,8 +12,8 @@
"dependencies": {
"@account-abstraction/sdk": "^0.5.0",
"@thirdweb-dev/chains": "^0.1.11",
- "@thirdweb-dev/sdk": "^3.10.15-nightly-49ec2d17-20230515214212",
- "@thirdweb-dev/wallets": "^0.2.20-nightly-49ec2d17-20230515214212",
+ "@thirdweb-dev/sdk": "0.0.0-dev-2067f33-20230609035419",
+ "@thirdweb-dev/wallets": "0.0.0-dev-2067f33-20230609035419",
"axios": "^1.3.4",
"dotenv": "^16.0.3",
"ethers": "^5"
diff --git a/sdk-calls.ts b/sdk-calls.ts
index 784e33d..10843db 100644
--- a/sdk-calls.ts
+++ b/sdk-calls.ts
@@ -32,8 +32,6 @@ export const claimToken = async (sdk: ThirdwebSDK) => {
);
console.timeEnd("contract");
- const tokenBalance = await contract.erc20.balance();
- console.log("token balance:", tokenBalance.displayValue);
console.time("claim");
console.time("prepare");
const tx = await contract.erc20.claim.prepare(1);
@@ -48,6 +46,8 @@ export const claimToken = async (sdk: ThirdwebSDK) => {
console.timeEnd("wait for confirmation");
console.timeEnd("claim");
console.log("claimed", receipt.transactionHash);
+ const tokenBalance = await contract.erc20.balance();
+ console.log("token balance:", tokenBalance.displayValue);
};
export const claimERC721Token = async (sdk: ThirdwebSDK) => {
@@ -74,6 +74,16 @@ export const claimMumbaiNFT = async (sdk: ThirdwebSDK) => {
console.log("claimed", tx.receipt.transactionHash);
};
+export const claimCeloToken = async (sdk: ThirdwebSDK) => {
+ const contract = await sdk.getContract(
+ "0x22AD454415D786D898468bEfBAF4e7d2145A86F9" // celo alfajores
+ );
+ const tx = await contract.erc20.claim(1);
+ console.log("claimed", tx.receipt.transactionHash);
+ const tokenBalance = await contract.erc20.balance();
+ console.log("token balance:", tokenBalance.displayValue);
+};
+
export const playCatAttack = async (
sdk: ThirdwebSDK,
personalWalletAddress: string
diff --git a/yarn.lock b/yarn.lock
index 1943851..810cde9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -40,93 +40,17 @@
resolved "https://registry.yarnpkg.com/@assemblyscript/loader/-/loader-0.9.4.tgz#a483c54c1253656bb33babd464e3154a173e1577"
integrity sha512-HazVq9zwTVwGmqdwYzu7WyQ6FQVZ7SwET0KKQuKm55jD0IfUpZgN0OPIiZG3zV1iSrVYcN0bdwLRXI/VNCYsUA==
-"@babel/compat-data@^7.17.7", "@babel/compat-data@^7.21.4":
- version "7.21.4"
- resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.21.4.tgz#457ffe647c480dff59c2be092fc3acf71195c87f"
- integrity sha512-/DYyDpeCfaVinT40FPGdkkb+lYSKvsVuMjDAG7jPOWWiM1ibOaB9CXJAlc4d1QpP/U2q2P9jbrSlClKSErd55g==
-
-"@babel/helper-compilation-targets@^7.17.7":
- version "7.21.4"
- resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.21.4.tgz#770cd1ce0889097ceacb99418ee6934ef0572656"
- integrity sha512-Fa0tTuOXZ1iL8IeDFUWCzjZcn+sJGd9RZdH9esYVjEejGmzf+FFYQpMi/kZUk2kPy/q1H3/GPw7np8qar/stfg==
- dependencies:
- "@babel/compat-data" "^7.21.4"
- "@babel/helper-validator-option" "^7.21.0"
- browserslist "^4.21.3"
- lru-cache "^5.1.1"
- semver "^6.3.0"
-
-"@babel/helper-define-polyfill-provider@^0.3.3":
- version "0.3.3"
- resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz#8612e55be5d51f0cd1f36b4a5a83924e89884b7a"
- integrity sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww==
- dependencies:
- "@babel/helper-compilation-targets" "^7.17.7"
- "@babel/helper-plugin-utils" "^7.16.7"
- debug "^4.1.1"
- lodash.debounce "^4.0.8"
- resolve "^1.14.2"
- semver "^6.1.2"
-
-"@babel/helper-module-imports@^7.21.4":
- version "7.21.4"
- resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.21.4.tgz#ac88b2f76093637489e718a90cec6cf8a9b029af"
- integrity sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==
- dependencies:
- "@babel/types" "^7.21.4"
-
-"@babel/helper-plugin-utils@^7.16.7", "@babel/helper-plugin-utils@^7.20.2":
- version "7.20.2"
- resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz#d1b9000752b18d0877cff85a5c376ce5c3121629"
- integrity sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ==
-
-"@babel/helper-string-parser@^7.19.4":
- version "7.19.4"
- resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63"
- integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==
-
-"@babel/helper-validator-identifier@^7.19.1":
- version "7.19.1"
- resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2"
- integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==
-
[... diff too long, it was truncated ...]
GitHub
sha: a79628223423cda62d8797d755739ce9f18ae7c7