Skip to content

Commit

Permalink
Random Wallet generation
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed Jan 11, 2023
1 parent 774375b commit d991b56
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/common/helpers/masa/index.ts
@@ -1,4 +1,5 @@
import { Masa } from '@masa-finance/masa-sdk';
import { ethers, Wallet } from 'ethers';

const config = {
...process.env,
Expand All @@ -10,13 +11,28 @@ const envs = {
test: 'https://test.middleware.masa.finance/',
local: 'http://localhost:4000/',
};


export const createRandomWallet = (): Wallet => {
console.info("Creating random wallet!");
const wallet = ethers.Wallet.createRandom();

wallet.connect(
new ethers.providers.JsonRpcProvider("https://rpc.ankr.com/eth_goerli")
);
return wallet;
};


export const createNewMasa = (
newWallet,
env: 'dev' | 'beta' | 'test' | 'local' = 'dev'
) => {

const signer = newWallet ? newWallet : createRandomWallet()
return new Masa({
cookie: config.cookie || undefined,
wallet: newWallet,
wallet: signer,
apiUrl: envs[env],
environment: config.environment || 'dev',
arweave: {
Expand Down

0 comments on commit d991b56

Please sign in to comment.