Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim code structure #63

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions networks/ethereum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<a href="https://github.com/cosmology-tech/interchainjs/blob/main/LICENSE-Apache"><img height="20" src="https://img.shields.io/badge/license-Apache-blue.svg"></a>
</p>


Transaction codec and client to communicate with ethereum blockchain.

## Usage
Expand All @@ -23,7 +22,7 @@ npm install @interchainjs/ethereum

## Implementations

- **eip712 signer** from `@interchainjs/ethereum/eip712` (Not fully implemented yet)
- **eip712 signer** from `@interchainjs/ethereum/eip712`

## License

Expand Down
19 changes: 0 additions & 19 deletions networks/ethereum/src/defaults.ts

This file was deleted.

1 change: 0 additions & 1 deletion networks/injective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"directory": "dist"
},
"scripts": {
"test": "jest --config ./jest.config.js --verbose --bail",
"copy": "copyfiles -f ../../LICENSE-MIT ../../LICENSE-Apache README.md package.json dist",
"clean": "rimraf dist/**",
"build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
Expand Down
101 changes: 0 additions & 101 deletions networks/injective/src/builder/eip712-tx-builder.ts

This file was deleted.

21 changes: 17 additions & 4 deletions networks/injective/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ import { toDecoder } from '@interchainjs/cosmos/utils';
import { BaseAccount } from '@interchainjs/cosmos-types/cosmos/auth/v1beta1/auth';
import { PubKey as Secp256k1PubKey } from '@interchainjs/cosmos-types/cosmos/crypto/secp256k1/keys';
import { EthAccount } from '@interchainjs/cosmos-types/injective/types/v1beta1/account';
import { defaultSignerConfig as EthereumSignerConfig } from '@interchainjs/ethereum/defaults';
import { Eip712Doc } from '@interchainjs/ethereum/types';
import { IKey, SignerConfig } from '@interchainjs/types';

import { DomainOptions, EthereumChainId } from './types';
import { bytes as assertBytes } from '@noble/hashes/_assert';
import { keccak_256 } from '@noble/hashes/sha3';
import { computeAddress } from '@ethersproject/transactions';
import { Key } from '@interchainjs/utils';

export const defaultPublicKeyConfig: SignerConfig['publicKey'] = {
isCompressed: CosmosSignerConfig.publicKey.isCompressed,
hash: EthereumSignerConfig.publicKey.hash,
hash: (publicKey: Key) => Key.fromHex(computeAddress(publicKey.value))
};

export const defaultEncodePublicKey = (key: IKey): EncodedMessage => {
Expand Down Expand Up @@ -50,15 +53,25 @@ export const defaultSignerOptions: Record<string, Required<SignerOptions>> = {
...CosmosSignerConfig,
message: {
...CosmosSignerConfig.message,
hash: EthereumSignerConfig.message.hash,
hash: (message: Uint8Array) => {
const hashed = keccak_256(message);
assertBytes(hashed);
return hashed;
},
},
publicKey: defaultPublicKeyConfig,
encodePublicKey: defaultEncodePublicKey,
parseAccount: defaultAccountParser,
prefix: 'inj',
},
Ethereum: {
...EthereumSignerConfig,
message: {
hash: (message: Uint8Array) => {
const hashed = keccak_256(message);
assertBytes(hashed);
return hashed;
},
},
publicKey: defaultPublicKeyConfig,
encodePublicKey: defaultEncodePublicKey,
parseAccount: defaultAccountParser,
Expand Down
11 changes: 0 additions & 11 deletions networks/injective/src/eth-utils/helpers.ts

This file was deleted.

Loading
Loading