Skip to content

Commit

Permalink
Runs prettier against entire codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
netbonus committed Dec 18, 2023
1 parent 58678d9 commit b2e4fb8
Show file tree
Hide file tree
Showing 76 changed files with 1,170 additions and 2,553 deletions.
54 changes: 27 additions & 27 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"env": {
"es6": false,
"mocha": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"globals": {
"expect": true,
"shallow": true,
"render": true,
"mount": true,
"beforeAll": true,
"cy": true
},
"rules": {
"eqeqeq": ["error"],
"no-var": ["warn"],
"no-duplicate-imports": ["error"],
"prefer-const": ["error"],
"prefer-spread": ["error"],
"no-console": ["off"],
"quotes": ["error", "single"],
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-explicit-any": "off"
"env": {
"es6": false,
"mocha": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"globals": {
"expect": true,
"shallow": true,
"render": true,
"mount": true,
"beforeAll": true,
"cy": true
},
"rules": {
"eqeqeq": ["error"],
"no-var": ["warn"],
"no-duplicate-imports": ["error"],
"prefer-const": ["error"],
"prefer-spread": ["error"],
"no-console": ["off"],
"quotes": ["error", "single"],
"react/react-in-jsx-scope": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
24 changes: 12 additions & 12 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"overrides": [
{
"files": "**/src/*.ts",
"options": {
"parser": "typescript"
}
}
],
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
"overrides": [
{
"files": "**/src/*.ts",
"options": {
"parser": "typescript"
}
}
],
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ formats: all
python:
version: 3.7
install:
- requirements: docs/requirements.txt
- requirements: docs/requirements.txt
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# GridPlus Lattice1 SDK

* **For help with this SDK, see the [GridPlus SDK Documentation](https://gridplus.github.io/gridplus-sdk)**
* **For help with your Lattice1 hardware, see the [Lattice1 Documentation](https://docs.gridplus.io)**
- **For help with this SDK, see the [GridPlus SDK Documentation](https://gridplus.github.io/gridplus-sdk)**
- **For help with your Lattice1 hardware, see the [Lattice1 Documentation](https://docs.gridplus.io)**

This SDK is designed to facilitate communication with a user's [Lattice1 hardware wallet](https://gridplus.io/lattice). Once paired to a given Lattice, an instance of this SDK is used to make encrypted requests for things like getting addresses/public keys and making signatures.

Expand Down
35 changes: 16 additions & 19 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>

</head>

<body>
<script type="module">
import { Buffer } from "buffer";
window.Buffer = Buffer;
window.global = window
</script>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
<body>
<script type="module">
import { Buffer } from 'buffer';
window.Buffer = Buffer;
window.global = window;
</script>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
64 changes: 32 additions & 32 deletions src/__test__/e2e/eth.msg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ describe('ETH Messages', () => {
});

describe('Test ETH EIP712', function () {

it('Should test a message that needs to be prehashed', async () => {
const msg = {
types: {
Expand All @@ -144,7 +143,7 @@ describe('ETH Messages', () => {
};
await runEthMsg(buildEthMsgReq(msg, 'eip712'), client);
});

it('Should test an example from Blur NFT w/ 0 fees', async () => {
const msg = {
types: {
Expand Down Expand Up @@ -173,7 +172,7 @@ describe('ETH Messages', () => {
{ name: 'salt', type: 'uint256' },
{ name: 'extraParams', type: 'bytes' },
{ name: 'nonce', type: 'uint256' },
{ name: 'fees', type: 'Fee[]'},
{ name: 'fees', type: 'Fee[]' },
],
},
domain: {
Expand All @@ -189,7 +188,8 @@ describe('ETH Messages', () => {
side: '1',
matchingPolicy: '0x00000000006411739da1c40b106f8511de5d1fac',
collection: '0x7a15b36cb834aea88553de69077d3777460d73ac',
tokenId: '5280336779268220421569573059971679349075200194886069432279714075018412552192',
tokenId:
'5280336779268220421569573059971679349075200194886069432279714075018412552192',
amount: '1',
paymentToken: '0x0000000000000000000000000000000000000000',
price: '990000000000000000',
Expand Down Expand Up @@ -275,38 +275,39 @@ describe('ETH Messages', () => {

it('Should test Vertex message', async () => {
const msg = {
'types': {
'EIP712Domain': [
{'name': 'name', 'type': 'string'},
{'name': 'version', 'type': 'string'},
{'name': 'chainId', 'type': 'uint256'},
{'name': 'verifyingContract', 'type': 'address'}
],
'Order': [
{'name': 'sender', 'type': 'bytes32'},
{'name': 'priceX18', 'type': 'int128'},
{'name': 'amount', 'type': 'int128'},
{'name': 'expiration', 'type': 'uint64'},
{'name': 'nonce', 'type': 'uint64'},
],
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
Order: [
{ name: 'sender', type: 'bytes32' },
{ name: 'priceX18', type: 'int128' },
{ name: 'amount', type: 'int128' },
{ name: 'expiration', type: 'uint64' },
{ name: 'nonce', type: 'uint64' },
],
},
'primaryType': 'Order',
'domain': {
'name': 'Vertex',
'version': '0.0.1',
'chainId': '42161',
'verifyingContract': '0xf03f457a30e598d5020164a339727ef40f2b8fbc'
primaryType: 'Order',
domain: {
name: 'Vertex',
version: '0.0.1',
chainId: '42161',
verifyingContract: '0xf03f457a30e598d5020164a339727ef40f2b8fbc',
},
'message': {
'sender': '0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000',
'priceX18': '28898000000000000000000',
'amount': '-10000000000000000',
'expiration': '4611687701117784255',
'nonce': '1764428860167815857',
message: {
sender:
'0x841fe4876763357975d60da128d8a54bb045d76a64656661756c740000000000',
priceX18: '28898000000000000000000',
amount: '-10000000000000000',
expiration: '4611687701117784255',
nonce: '1764428860167815857',
},
};
await runEthMsg(buildEthMsgReq(msg, 'eip712'), client);
})
});

it('Should test a large 1inch transaction', async () => {
const msg = {
Expand Down Expand Up @@ -1305,6 +1306,5 @@ describe('ETH Messages', () => {
});
}
});

});
});
42 changes: 18 additions & 24 deletions src/__test__/e2e/general.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
*/
import { TransactionFactory as EthTxFactory } from '@ethereumjs/tx';
import { question } from 'readline-sync';
import {
HARDENED_OFFSET,
LatticeResponseCode,
} from '../../constants';
import { ProtocolConstants, LatticeResponseCode } from '../../protocol';
import { HARDENED_OFFSET, LatticeResponseCode } from '../../constants';
import { LatticeResponseCode, ProtocolConstants } from '../../protocol';
import { randomBytes } from '../../util';
import { buildEthSignRequest } from '../utils/builders';
import { getDeviceId } from '../utils/getters';
Expand Down Expand Up @@ -50,14 +47,14 @@ describe('General', () => {

const client1 = setupTestClient();
await client1.connect(id);
expect(client1.isPaired).toBeTruthy()
expect(client1.isPaired).toBeTruthy();
const addrs1 = await client1.getAddresses(addrData);

const stateData = client1.getStateData();

const client2 = setupTestClient(null, stateData);
await client2.connect(id);
expect(client2.isPaired).toBeTruthy()
expect(client2.isPaired).toBeTruthy();
const addrs2 = await client2.getAddresses(addrData);

expect(addrs1).toEqual(addrs2);
Expand Down Expand Up @@ -153,20 +150,17 @@ describe('General', () => {
const { req } = await buildEthSignRequest(client);
await client.sign(req);
});

it('should sign newer transactions', async () => {
const { txData, req, common } = await buildEthSignRequest(
client,
{
type: 1,
gasPrice: 1200000000,
nonce: 0,
gasLimit: 50000,
to: '0xe242e54155b1abc71fc118065270cecaaf8b7768',
value: 1000000000000,
data: '0x17e914679b7e160613be4f8c2d3203d236286d74eb9192f6d6f71b9118a42bb033ccd8e8',
}
);
const { txData, req, common } = await buildEthSignRequest(client, {
type: 1,
gasPrice: 1200000000,
nonce: 0,
gasLimit: 50000,
to: '0xe242e54155b1abc71fc118065270cecaaf8b7768',
value: 1000000000000,
data: '0x17e914679b7e160613be4f8c2d3203d236286d74eb9192f6d6f71b9118a42bb033ccd8e8',
});
// NOTE: This will display a prehashed payload for bridged general signing
// requests because `ethMaxDataSz` represents the `data` field for legacy
// requests, but it represents the entire payload for general signing requests.
Expand All @@ -176,19 +170,20 @@ describe('General', () => {
});

it('should sign bad transactions', async () => {
const { txData, req, maxDataSz, common } = await buildEthSignRequest(client);
const { txData, req, maxDataSz, common } = await buildEthSignRequest(
client,
);
await question(
'Please REJECT the next request if the warning screen displays. Press enter to continue.',
);
txData.data = randomBytes(maxDataSz)
txData.data = randomBytes(maxDataSz);
req.data.data = randomBytes(maxDataSz + 1);
const tx = EthTxFactory.fromTxData(txData, { common });
req.data.payload = tx.getMessageToSign(false);
await expect(client.sign(req)).rejects.toThrow(
`${ProtocolConstants.responseMsg[LatticeResponseCode.userDeclined]}`,
);
});

});

describe('Should sign Bitcoin transactions', () => {
Expand Down Expand Up @@ -348,5 +343,4 @@ describe('General', () => {
expect(sigResp.changeRecipient?.slice(0, 2)).toEqual('tb');
});
});

});
16 changes: 5 additions & 11 deletions src/__test__/e2e/kv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DEFAULT_SIGNER } from '../utils/builders';
*/
import { question } from 'readline-sync';
import { HARDENED_OFFSET } from '../../constants';
import { ProtocolConstants, LatticeResponseCode } from '../../protocol';
import { LatticeResponseCode, ProtocolConstants } from '../../protocol';
import { BTC_PURPOSE_P2PKH, ETH_COIN } from '../utils/helpers';
import { initializeClient } from '../utils/initializeClient';

Expand Down Expand Up @@ -61,9 +61,9 @@ describe('key-value', () => {
it('Should notify the user when to approve requests', async () => {
question(
'\nNOTE: ONLY APPROVE REQUESTS THAT RENDER TAGS FOR THIS TEST SCRIPT.\n' +
'Press ENTER to continue.'
)
})
'Press ENTER to continue.',
);
});

it('Should make a request to an unknown address', async () => {
await client.sign(ETH_REQ).catch((err) => {
Expand Down Expand Up @@ -150,13 +150,7 @@ describe('key-value', () => {
const req = {
currency: 'ETH_MSG',
data: {
signerPath: [
BTC_PURPOSE_P2PKH,
ETH_COIN,
HARDENED_OFFSET,
0,
0,
],
signerPath: [BTC_PURPOSE_P2PKH, ETH_COIN, HARDENED_OFFSET, 0, 0],
protocol: 'eip712',
payload: msg,
},
Expand Down
Loading

0 comments on commit b2e4fb8

Please sign in to comment.