Skip to content

Commit

Permalink
add quick test for roger
Browse files Browse the repository at this point in the history
  • Loading branch information
netbonus committed Aug 5, 2024
1 parent 1a1f9da commit 83dc9a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 110 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"test-utils": "vitest src/__test__/utils/__test__/",
"e2e": "vitest src/__test__/e2e",
"e2e-btc": "vitest src/__test__/e2e/btc.test.ts",
"rog-test": "vitest src/__test__/e2e/bug.test.ts",
"e2e-eth": "vitest src/__test__/e2e/eth.msg.test.ts",
"e2e-gen": "vitest src/__test__/e2e/general.test.ts",
"e2e-kv": "vitest src/__test__/e2e/kv.test.ts",
Expand Down
102 changes: 3 additions & 99 deletions src/__test__/e2e/bug.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable quotes */
import { question } from 'readline-sync';
import { getClient, pair } from '../../api';
import { sign } from '../../api/index';
import { fetchAddressesByDerivationPath, pair } from '../../api';
import { setupClient } from '../utils/setup';

describe('bug', () => {
Expand All @@ -13,102 +12,7 @@ describe('bug', () => {
}
});

test('payload', async () => {
const client = getClient();
await client.sign({
currency: 'ETH_MSG',
data: {
signerPath: [2147483692, 2147483708, 2147483648, 0, 0],
protocol: 'eip712',
payload: {
types: {
EIP712Domain: [
{
name: 'name',
type: 'string',
},
{
name: 'version',
type: 'string',
},
{
name: 'chainId',
type: 'uint256',
},
{
name: 'verifyingContract',
type: 'address',
},
],
Group: [
{
name: 'name',
type: 'string',
},
{
name: 'members',
type: 'Person[]',
},
],
Mail: [
{
name: 'from',
type: 'Person',
},
{
name: 'to',
type: 'Person[]',
},
{
name: 'contents',
type: 'string',
},
{
name: 'attachment',
type: 'bytes',
},
],
Person: [
{
name: 'name',
type: 'string',
},
{
name: 'wallets',
type: 'address[]',
},
],
},
primaryType: 'Mail',
domain: {
chainId: '0xaa36a7',
name: 'Ether Mail',
verifyingContract: '0xcccccccccccccccccccccccccccccccccccccccc',
version: '1',
},
message: {
contents: 'Hello, Bob!',
from: {
name: 'Cow',
wallets: [
'0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826',
'0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
],
},
to: [
{
name: 'Bob',
wallets: [
'0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'0xb0bdabea57b0bdabea57b0bdabea57b0bdabea57',
'0xb0b0b0b0b0b0b000000000000000000000000000',
],
},
],
attachment: '0x',
},
},
},
});
test('fetch cosmos', async () => {
await fetchAddressesByDerivationPath(`1852'/1815'/0'/0/0`);
});
});
22 changes: 11 additions & 11 deletions src/functions/getAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ export const encodeGetAddressesRequest = ({
fwConstants: FirmwareConstants;
wallet: Wallet;
}) => {
const flags = fwConstants.getAddressFlags || ([] as any[]);
const isPubkeyOnly =
flags.indexOf(flag) > -1 &&
(flag === LatticeGetAddressesFlag.ed25519Pubkey ||
flag === LatticeGetAddressesFlag.secp256k1Pubkey ||
flag === LatticeGetAddressesFlag.bls12_381Pubkey);
if (!isPubkeyOnly && !isValidAssetPath(startPath, fwConstants)) {
throw new Error(
'Derivation path or flag is not supported. Try updating Lattice firmware.',
);
}
// const flags = fwConstants.getAddressFlags || ([] as any[]);
// const isPubkeyOnly =
// flags.indexOf(flag) > -1 &&
// (flag === LatticeGetAddressesFlag.ed25519Pubkey ||
// flag === LatticeGetAddressesFlag.secp256k1Pubkey ||
// flag === LatticeGetAddressesFlag.bls12_381Pubkey);
// if (!isPubkeyOnly && !isValidAssetPath(startPath, fwConstants)) {
// throw new Error(
// 'Derivation path or flag is not supported. Try updating Lattice firmware.',
// );
// }
let sz = 32 + 20 + 1; // walletUID + 5 u32 indices + count/flag
if (fwConstants.varAddrPathSzAllowed) {
sz += 1; // pathDepth
Expand Down

0 comments on commit 83dc9a9

Please sign in to comment.