Skip to content

Commit 60403ec

Browse files
committed
fix: injective pubkey decoder + starship jest ESM
1 parent fa4b5be commit 60403ec

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

networks/cosmos/jest.starship.config.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@ module.exports = {
44
preset: 'ts-jest',
55
testEnvironment: 'node',
66
transform: {
7-
'^.+\\.tsx?$': [
7+
'^.+\\.[jt]sx?$': [
88
'ts-jest',
99
{
10-
babelConfig: false,
11-
tsconfig: 'tsconfig.json',
12-
diagnostics: false,
10+
tsconfig: {
11+
moduleResolution: 'node',
12+
allowJs: true,
13+
esModuleInterop: true,
14+
skipLibCheck: true,
15+
strict: false,
16+
},
17+
isolatedModules: true,
1318
},
1419
],
1520
},
16-
transformIgnorePatterns: [`/node_modules/*`],
21+
transformIgnorePatterns: [`node_modules/(?!(.pnpm|@noble/hashes|@noble/curves|@scure/bip32|@scure/base|bech32|bs58|base-x))`],
1722
modulePathIgnorePatterns: ['<rootDir>/dist/'],
1823
testRegex: '/starship/__tests__/.*\\.(test|spec)\\.(jsx?|tsx?)$',
1924
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],

networks/ethereum/jest.starship.config.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ module.exports = {
44
preset: 'ts-jest',
55
testEnvironment: 'node',
66
transform: {
7-
'^.+\\.tsx?$': [
7+
'^.+\\.[jt]sx?$': [
88
'ts-jest',
99
{
10-
babelConfig: false,
11-
tsconfig: 'tsconfig.json',
10+
tsconfig: {
11+
moduleResolution: 'node',
12+
allowJs: true,
13+
esModuleInterop: true,
14+
skipLibCheck: true,
15+
strict: false,
16+
},
17+
isolatedModules: true,
1218
},
1319
],
1420
},
15-
transformIgnorePatterns: [`/node_modules/*`],
21+
transformIgnorePatterns: [`node_modules/(?!(.pnpm|@noble/hashes|@noble/curves|@scure/bip32|@scure/base|bech32|bs58|base-x))`],
1622
modulePathIgnorePatterns: ['<rootDir>/dist/'],
1723
testRegex: '/starship/__tests__/.*\\.(test|spec)\\.(jsx?|tsx?)$',
1824
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],

networks/injective/src/signers/config.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { PRESET_INJECTIVE_SIGNATURE_FORMATS } from './signature-processor';
22
import deepmerge from 'deepmerge';
3-
import { CosmosCryptoSecp256k1PubKey as Secp256k1PubKey } from '@interchainjs/cosmos-types';
3+
import { CosmosCryptoSecp256k1PubKey } from '@interchainjs/cosmos-types';
44
import { EncodedMessage, DocOptions, CosmosSignerConfig } from '@interchainjs/cosmos';
55
import { Any } from '@interchainjs/types';
66

@@ -11,8 +11,8 @@ import { Any } from '@interchainjs/types';
1111
export const encodeInjectivePublicKey = (publicKey: Uint8Array): EncodedMessage => {
1212
return {
1313
typeUrl: '/injective.crypto.v1beta1.ethsecp256k1.PubKey',
14-
value: Secp256k1PubKey.encode(
15-
Secp256k1PubKey.fromPartial({ key: publicKey })
14+
value: CosmosCryptoSecp256k1PubKey.encode(
15+
CosmosCryptoSecp256k1PubKey.fromPartial({ key: publicKey })
1616
).finish(),
1717
};
1818
};
@@ -45,9 +45,12 @@ export const DEFAULT_INJECTIVE_SIGNER_CONFIG: Partial<DocOptions> = {
4545
// Public key encoding - Injective specific
4646
encodePublicKey: encodeInjectivePublicKey,
4747
pubkeyDecoders: {
48-
'/injective.crypto.v1beta1.ethsecp256k1.PubKey': (pubkey: Any): Secp256k1PubKey => {
49-
const { key } = Secp256k1PubKey.decode(pubkey.value);
50-
return Secp256k1PubKey.fromPartial({ key });
48+
'/injective.crypto.v1beta1.ethsecp256k1.PubKey': (pubkey: Any) => {
49+
const { key } = CosmosCryptoSecp256k1PubKey.decode(pubkey.value);
50+
return {
51+
type: 'tendermint/PubKeySecp256k1',
52+
value: Buffer.from(key).toString('base64'),
53+
};
5154
}
5255
}
5356
};

0 commit comments

Comments
 (0)