Skip to content

Commit

Permalink
Merge pull request #1 from Mintbase/format-types
Browse files Browse the repository at this point in the history
[CI] Lint & Format & Types
  • Loading branch information
bh2smith authored Mar 13, 2024
2 parents 4811751 + 554ff18 commit 687d39e
Show file tree
Hide file tree
Showing 19 changed files with 4,410 additions and 114 deletions.
29 changes: 29 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error","always"],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {
"allowExpressions": true,
"allowTypedFunctionExpressions": true
}]
}
}
24 changes: 24 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install Dependencies
run: npm install

- name: Lint
run: npm run lint
Binary file removed bun.lockb
Binary file not shown.
12 changes: 6 additions & 6 deletions examples/buy-nft.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {
deriveEthAddress,
signAndSendTransaction
} from "../src/chains/ethereum";
import { setupAccount } from "./setup";

const run = async () => {
const sender = await deriveEthAddress("ethereum,1");
const run = async (): Promise<void> => {
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,
seaportAddress,
Expand Down
8 changes: 4 additions & 4 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 () => {
const ethAddress = await deriveEthAddress("ethereum,1");
const run = async (): Promise<void> => {
const sender = await setupAccount();
const functionSignature = web3.eth.abi.encodeFunctionCall(
{
name: "safeMint",
Expand All @@ -21,7 +21,7 @@ const run = async () => {
);

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

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

await signAndSendTransaction(
ethAddress,
sender,
"0xAA5FcF171dDf9FE59c985A28747e650C2e9069cA",
0.001
);
Expand Down
8 changes: 4 additions & 4 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"
} from "../src/utils/interfaces";
import { setupAccount } from "./setup";



const run = async () => {
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");
}
10 changes: 5 additions & 5 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 () => {
const sender = await deriveEthAddress("ethereum,1");
const run = async (): Promise<void> => {
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
Loading

0 comments on commit 687d39e

Please sign in to comment.