Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/wacky-windows-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainwright": patch
---

Add example folders for wallet setup
18 changes: 18 additions & 0 deletions examples/custom-extension-source/custom-download-url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineWalletSetup } from "chainwright/core";

const PASSWORD = "test1234";
const EXTENSION_DOWNLOAD_URL = "https://example.com/metamask-extension.zip";
const EXTENSION_SHA256 = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";

export default defineWalletSetup(
PASSWORD,
async () => {
//.. Onboarding logi. here
},
{
extensionSource: {
downloadUrl: EXTENSION_DOWNLOAD_URL,
sha256: EXTENSION_SHA256,
},
},
);
17 changes: 17 additions & 0 deletions examples/custom-extension-source/local-path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineWalletSetup } from "chainwright/core";

const PASSWORD = "test1234";
//const LOCAL_EXTENSION_ZIP = path.resolve(process.cwd(), "your path")
const LOCAL_EXTENSION_ZIP = "/absolute/path/to/metamask-extension.zip";

export default defineWalletSetup(
PASSWORD,
async () => {
//... Onboarding logic here
},
{
extensionSource: {
localPath: LOCAL_EXTENSION_ZIP,
},
},
);
13 changes: 13 additions & 0 deletions examples/custom-profile/fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { testWithChainwright } from "chainwright/core";
import { metamaskFixture } from "chainwright/metamask";

export const testWithTeamProfile = testWithChainwright(
metamaskFixture({
profileName: "team-profile",
}),
);

// Your Fixture here!
export const customFixture = testWithTeamProfile.extend({
// fixture properties
});
19 changes: 19 additions & 0 deletions examples/custom-profile/metamask.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineWalletSetup } from "chainwright/core";
import { Metamask } from "chainwright/metamask";

const PASSWORD = "test1234";
const SECRET_RECOVERY_PHRASE = "Your secret phrase";

export default defineWalletSetup(
PASSWORD,
async ({ walletPage }) => {
const metamask = new Metamask(walletPage);

await metamask.onboard({
mode: "import",
secretRecoveryPhrase: SECRET_RECOVERY_PHRASE,
mainAccountName: "Team profile",
});
},
{ profileName: "team-profile" },
);
36 changes: 36 additions & 0 deletions examples/custom-profile/meteor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { defineWalletSetup } from "chainwright/core";
import { Meteor } from "chainwright/meteor";

const PASSWORD = "test1234";
const DEFAULT_PRIVATE_KEY = "Your private key";
const TESTNET_PRIVATE_KEY = "Your private key";
const MAINNET_PRIVATE_KEY = "Your private key";

export default defineWalletSetup(
PASSWORD,
async ({ walletPage }) => {
const meteor = new Meteor(walletPage);

await meteor.onboard({
mode: "privateKey",
privateKey: DEFAULT_PRIVATE_KEY,
accountName: "Default",
network: "Testnet",
additionalAccounts: [
{
mode: "privateKey",
privateKey: TESTNET_PRIVATE_KEY,
accountName: "Testnet account",
network: "Testnet",
},
{
mode: "privateKey",
privateKey: MAINNET_PRIVATE_KEY,
accountName: "Mainnet account",
network: "Mainnet",
},
],
});
},
{ profileName: "multiple-network" },
);
25 changes: 25 additions & 0 deletions examples/multiple-accounts/keplr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineWalletSetup } from "chainwright/core";
import { Keplr } from "chainwright/keplr";

const PASSWORD = "test1234";
const FIRST_PRIVATE_KEY = "Your private key";
const SECOND_PRIVATE_KEY = "Your private key";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const keplr = new Keplr(walletPage);

await keplr.onboard([
{
mode: "privateKey",
privateKey: FIRST_PRIVATE_KEY,
walletName: "Default",
chains: ["Injective", "Injective (Testnet)"],
},
{
mode: "privateKey",
privateKey: SECOND_PRIVATE_KEY,
walletName: "Trading",
chains: ["Injective", "Injective (Testnet)"],
},
]);
});
32 changes: 32 additions & 0 deletions examples/multiple-accounts/meteor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { defineWalletSetup } from "chainwright/core";
import { Meteor } from "chainwright/meteor";

const PASSWORD = "test1234";
const DEFAULT_PRIVATE_KEY = "Your private key";
const TESTNET_PRIVATE_KEY = "Your private key";
const MAINNET_PRIVATE_KEY = "Your private key";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const meteor = new Meteor(walletPage);

await meteor.onboard({
mode: "privateKey",
privateKey: DEFAULT_PRIVATE_KEY,
accountName: "Default",
network: "Testnet",
additionalAccounts: [
{
mode: "privateKey",
privateKey: TESTNET_PRIVATE_KEY,
accountName: "Testnet account",
network: "Testnet",
},
{
mode: "privateKey",
privateKey: MAINNET_PRIVATE_KEY,
accountName: "Mainnet account",
network: "Mainnet",
},
],
});
});
24 changes: 24 additions & 0 deletions examples/multiple-accounts/petra.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineWalletSetup } from "chainwright/core";
import { Petra } from "chainwright/petra";

const PASSWORD = "PlayerPetra45!!";
const SECRET_RECOVERY_PHRASE = "Your secret phrase";
const SECOND_PRIVATE_KEY = "Your private key";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const petra = new Petra(walletPage);

await petra.onboard({
mode: "importMnemonic",
secretRecoveryPhrase: SECRET_RECOVERY_PHRASE,
accountName: "Default",
network: "Testnet",
additionalAccounts: [
{
mode: "privateKey",
privateKey: SECOND_PRIVATE_KEY,
accountName: "Imported account",
},
],
});
});
28 changes: 28 additions & 0 deletions examples/multiple-accounts/phantom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineWalletSetup } from "chainwright/core";
import { Phantom } from "chainwright/phantom";

const PASSWORD = "test1234";
const SECRET_RECOVERY_PHRASE = "Your secret phrase";
const ETHEREUM_PRIVATE_KEY = "Your private key";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const phantom = new Phantom(walletPage);

await phantom.onboard({
mode: "recovery phrase",
secretRecoveryPhrase: SECRET_RECOVERY_PHRASE,
accountName: "Default",
toggleNetworkMode: {
mode: "on",
chain: "Solana",
network: "Solana Devnet",
},
additionalAccounts: [
{
accountName: "Ethereum account",
chain: "Ethereum",
privateKey: ETHEREUM_PRIVATE_KEY,
},
],
});
});
22 changes: 22 additions & 0 deletions examples/multiple-accounts/solflare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { defineWalletSetup } from "chainwright/core";
import { Solflare } from "chainwright/solflare";

const PASSWORD = "test1234";
const RECOVERY_PHRASE = "Your secret phrase";
const SECOND_PRIVATE_KEY = "Your private key";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const solflare = new Solflare(walletPage);

await solflare.onboard({
recoveryPhrase: RECOVERY_PHRASE,
walletName: "Default",
network: "Devnet",
additionalAccounts: [
{
walletName: "Imported account",
privateKey: SECOND_PRIVATE_KEY,
},
],
});
});
18 changes: 18 additions & 0 deletions examples/single-account/keplr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineWalletSetup } from "chainwright/core";
import { Keplr } from "chainwright/keplr";

const PASSWORD = "test1234";
const PRIVATE_KEY = "Your private key";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const keplr = new Keplr(walletPage);

await keplr.onboard([
{
mode: "privateKey",
privateKey: PRIVATE_KEY,
walletName: "Default",
chains: ["Injective", "Injective (Testnet)"],
},
]);
});
28 changes: 28 additions & 0 deletions examples/single-account/metamask.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineWalletSetup } from "chainwright/core";
import { Metamask } from "chainwright/metamask";

/**
* Setting up MetaMask.
*
* MetaMask uses an Hierarchical Deterministic (HD) wallet model: the seed phrase
* is the root secret, and accounts are deterministically derived from it using
* derivative paths like m/44'/60'/0'/0/n.
*
* So, when you import an account using the seed phrase, MetaMask can recreate the
* same sequence of addresses by deriving the already existing accounts in the wallet.
* This is why we don't need an "additionalAccounts" argument in the onboarding action
* for the MetaMask wallet.
*/

const PASSWORD = "test1234";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const metamask = new Metamask(walletPage);
const seedPhrase = "Your secret phrase";

await metamask.onboard({
mode: "import",
secretRecoveryPhrase: seedPhrase,
mainAccountName: "Test",
});
});
16 changes: 16 additions & 0 deletions examples/single-account/meteor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineWalletSetup } from "chainwright/core";
import { Meteor } from "chainwright/meteor";

const PASSWORD = "test1234";
const PRIVATE_KEY = "Your private key";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const meteor = new Meteor(walletPage);

await meteor.onboard({
mode: "privateKey",
privateKey: PRIVATE_KEY,
accountName: "Default",
network: "Testnet",
});
});
16 changes: 16 additions & 0 deletions examples/single-account/petra.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineWalletSetup } from "chainwright/core";
import { Petra } from "chainwright/petra";

const PASSWORD = "TestPetra45!!";
const SECRET_RECOVERY_PHRASE = "Your secret phrase";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const petra = new Petra(walletPage);

await petra.onboard({
mode: "importMnemonic",
secretRecoveryPhrase: SECRET_RECOVERY_PHRASE,
accountName: "Default",
network: "Testnet",
});
});
20 changes: 20 additions & 0 deletions examples/single-account/phantom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defineWalletSetup } from "chainwright/core";
import { Phantom } from "chainwright/phantom";

const PASSWORD = "test1234";
const SECRET_RECOVERY_PHRASE = "Your secret phrase";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const phantom = new Phantom(walletPage);

await phantom.onboard({
mode: "recovery phrase",
secretRecoveryPhrase: SECRET_RECOVERY_PHRASE,
accountName: "Default",
toggleNetworkMode: {
mode: "on",
chain: "Solana",
network: "Solana Devnet",
},
});
});
15 changes: 15 additions & 0 deletions examples/single-account/solflare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineWalletSetup } from "chainwright/core";
import { Solflare } from "chainwright/solflare";

const PASSWORD = "test1234";
const RECOVERY_PHRASE = "Your secret phrase";

export default defineWalletSetup(PASSWORD, async ({ walletPage }) => {
const solflare = new Solflare(walletPage);

await solflare.onboard({
recoveryPhrase: RECOVERY_PHRASE,
walletName: "Default",
network: "Devnet",
});
});