Skip to content

Commit

Permalink
Merge pull request #63 from cosmology-tech/trim-code-structure
Browse files Browse the repository at this point in the history
Trim code structure
  • Loading branch information
Zetazzz authored Nov 26, 2024
2 parents 8f51bdd + c516a0d commit 9eae7b9
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 920 deletions.
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

0 comments on commit 9eae7b9

Please sign in to comment.