Skip to content

Commit

Permalink
fix env var processing
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Mar 12, 2024
1 parent 6fce557 commit 554ff18
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
8 changes: 4 additions & 4 deletions examples/buy-nft.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
deriveEthAddress,
signAndSendTransaction
} from "../src/chains/ethereum";
import { setupAccount } from "./setup";

const run = async (): Promise<void> => {
const sender = await deriveEthAddress("ethereum,1");
const sender = await setupAccount();
// TODO - encode call Data from OpenSeaSDK.
// https://github.com/ProjectOpenSea/opensea-js/blob/main/developerDocs/advanced-use-cases.md
const seaportAddress = "0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC";
const salePrice = 0.05;
const callData = "0x0000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ad31dde0cce000000000000000000000000000262d23a2d916f6cf08e0235315aa51e22d142d0b000000000000000000000000004c00500000ad104d7dbd00e3ae0a5c00560c00000000000000000000000000d4b922e90cb5daa6422ac018acde78dbbe23e4eb0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065f014fb000000000000000000000000000000000000000000000000000000006618e56b0000000000000000000000000000000000000000000000000000000000000000360c6ebe000000000000000000000000000000000000000030c75abf8edea43a0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000470de4df820000000000000000000000000000000a26b00c1f0df003000390027140000faa71900000000000000000000000000000000000000000000000000000000000000400f00e0a3e6be600317f02b2787804d9718ebfbd8016933ab48c8153396a5359038104375bdc311d1f21ed2af05e504c9c16b7482cc2bbed57663dd234ea1a4dd00000000360c6ebe";
const salePrice = 0.1;
const callData = "0x00000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015a63bbc199c0000000000000000000000000008d99f8b2710e6a3b94d9bf465a98e5273069acbd000000000000000000000000004c00500000ad104d7dbd00e3ae0a5c00560c00000000000000000000000000d4b922e90cb5daa6422ac018acde78dbbe23e4eb0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065eef070000000000000000000000000000000000000000000000000000000006617c0e00000000000000000000000000000000000000000000000000000000000000000360c6ebe00000000000000000000000000000000000000001561f4d71353b5740000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000008e1bc9bf040000000000000000000000000000000a26b00c1f0df003000390027140000faa7190000000000000000000000000000000000000000000000000000000000000040420a0b17bb103f09242108316294c491ea7dbf43d9a7c07373a395fcfc9147242e05c8d7700733851114fc85dc50789c612739b6cdcc2254f25132eb5eb76f5600000000360c6ebe";

await signAndSendTransaction(
sender,
Expand Down
6 changes: 3 additions & 3 deletions examples/mint-nft.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
deriveEthAddress,
signAndSendTransaction,
web3,
} from "../src/chains/ethereum";
import { setupAccount } from "./setup";

const run = async (): Promise<void> => {
const ethAddress = await deriveEthAddress("ethereum,1");
const sender = await setupAccount();
const functionSignature = web3.eth.abi.encodeFunctionCall(
{
name: "safeMint",
Expand All @@ -21,7 +21,7 @@ const run = async (): Promise<void> => {
);

await signAndSendTransaction(
ethAddress,
sender,
"0xAA5FcF171dDf9FE59c985A28747e650C2e9069cA",
0,
functionSignature
Expand Down
6 changes: 3 additions & 3 deletions examples/send-eth.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
deriveEthAddress,
signAndSendTransaction
} from "../src/chains/ethereum";
import dotenv from "dotenv";
import { setupAccount } from "./setup";
dotenv.config();

const run = async (): Promise<void> => {
const ethAddress = await deriveEthAddress("ethereum,1");
const sender = await setupAccount();

await signAndSendTransaction(
ethAddress,
sender,
"0xAA5FcF171dDf9FE59c985A28747e650C2e9069cA",
0.001
);
Expand Down
4 changes: 2 additions & 2 deletions examples/set-approval-for-all.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {
deriveEthAddress,
signAndSendTransaction,
} from "../src/chains/ethereum";
import {
erc721Interface
} from "../src/utils/interfaces";
import { setupAccount } from "./setup";



const run = async (): Promise<void> => {

const sender = await deriveEthAddress("ethereum,1");
const sender = await setupAccount();
const value = 0;
const tokenAddress = "0xe66be37f6b446079fe71a497312996dff6bd963f";
const operator = "0x8d99F8b2710e6A3B94d9bf465A98E5273069aCBd";
Expand Down
8 changes: 8 additions & 0 deletions examples/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import dotenv from "dotenv";
import { deriveEthAddress } from "../src/chains/ethereum";
dotenv.config();

export async function setupAccount(): Promise<string> {
return deriveEthAddress("ethereum,1");
}
8 changes: 4 additions & 4 deletions examples/transfer-nft.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
deriveEthAddress,
signAndSendTransaction
} from "../src/chains/ethereum";
import { erc721Interface } from "../src/utils/interfaces";
import { setupAccount } from "./setup";

const run = async (): Promise<void> => {
const sender = await deriveEthAddress("ethereum,1");
const sender = await setupAccount();
const value = 0;
// TODO retrieve from user:
const tokenAddress = "0xe66be37f6b446079fe71a497312996dff6bd963f";
const tokenId = 2;
const tokenAddress = "0xd4b922e90cb5daa6422ac018acde78dbbe23e4eb";
const tokenId = 3;
const to = "0x8d99F8b2710e6A3B94d9bf465A98E5273069aCBd";

const callData = erc721Interface().encodeFunctionData("safeTransferFrom(address,address,uint256)", [sender, to, tokenId]);
Expand Down

0 comments on commit 554ff18

Please sign in to comment.