Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
ca7e470
clean up packages for refactoring
Zetazzz Jun 21, 2025
c3acf9b
add architecture and builder docs
Zetazzz Jun 21, 2025
e2e79b4
add base workflow builder types
Zetazzz Jun 24, 2025
fff04de
add cosmos types
Zetazzz Jun 25, 2025
c0eea9b
add dev-docs/query-client-thoughts.md
Zetazzz Jun 25, 2025
d50d311
refined query client thoughts
Zetazzz Jun 25, 2025
1d3cc81
removed old query client thoughts
Zetazzz Jun 25, 2025
0397a9e
implementing query client
Zetazzz Jun 26, 2025
e027018
overall guide
Zetazzz Jun 26, 2025
abaa470
fix overall guide
Zetazzz Jun 26, 2025
457226e
backing up query client
Zetazzz Jun 26, 2025
9b7ac47
removed tests
Zetazzz Jun 26, 2025
ffc9cf2
add starship redirect script and test
Zetazzz Jun 26, 2025
804d85e
add jest starship config
Zetazzz Jun 26, 2025
bdf415e
remove starship query test
Zetazzz Jun 26, 2025
4fddc6f
working tests for query client
Zetazzz Jun 26, 2025
ce3892f
added rpc test
Zetazzz Jun 27, 2025
ac07a75
query client refactor
Zetazzz Jun 27, 2025
00da3de
done dev adapters
Zetazzz Jun 28, 2025
06493f5
added test
Zetazzz Jun 28, 2025
25d43a9
fix imports
Zetazzz Jun 28, 2025
1b71aa3
fix tests
Zetazzz Jun 30, 2025
1ddb9de
partially fix rpc tests
Zetazzz Jun 30, 2025
1c80fc1
fix build of rpc tests
Zetazzz Jun 30, 2025
17084ed
fix some rpc tests
Zetazzz Jun 30, 2025
83a0814
fix more rpc tests
Zetazzz Jun 30, 2025
3f6a2e5
fixed all rpc tests
Zetazzz Jun 30, 2025
52ed48e
fixed all rpc tests
Zetazzz Jun 30, 2025
7128ba1
fix starship tests
Zetazzz Jun 30, 2025
059a576
fix rpc tests version related tests
Zetazzz Jun 30, 2025
0bb6c1f
fixed starship tests
Zetazzz Jun 30, 2025
b7683d8
implement broadcast methods
Zetazzz Jul 1, 2025
5fd48e4
adapte 34 and 37 broadcast methods
Zetazzz Jul 1, 2025
d68bc16
remove docs
Zetazzz Jul 1, 2025
831355b
remove docs
Zetazzz Jul 1, 2025
0e54a6e
Merge branch 'main' into major-refactor-unisigner
Zetazzz Jul 2, 2025
aa51384
add agents docs
Zetazzz Jul 2, 2025
08c09af
add signers and workflows
Zetazzz Jul 2, 2025
1f7936a
remove unused files
Zetazzz Jul 6, 2025
85251d7
handle auth and offline signer in wf
Zetazzz Jul 6, 2025
5ccf7ba
handle signature
Zetazzz Jul 7, 2025
89edd64
add secp256k1hd wallet
Zetazzz Jul 7, 2025
b1d533f
remove simple wallet
Zetazzz Jul 7, 2025
9ff07e4
implement ISigningClient interface
Zetazzz Jul 7, 2025
1e7d323
rearrange dev docs
Zetazzz Jul 9, 2025
68e9583
edit dev docs
Zetazzz Jul 9, 2025
1514f27
refactored queries
Zetazzz Jul 12, 2025
3055c05
fixed starship tests
Zetazzz Jul 12, 2025
27ca451
auth and wallet refactoring complete
Zetazzz Jul 14, 2025
e306f31
fixed build
Zetazzz Jul 14, 2025
1a73115
rename methods and fields in IWallet
Zetazzz Jul 15, 2025
a41e3fc
fix: fix build errors for signers and wallets
Zetazzz Jul 17, 2025
a886f0b
getBaseAccount done
Zetazzz Jul 17, 2025
7c18351
tested wallet
Zetazzz Jul 17, 2025
6a0edee
remove redundant docs
Zetazzz Jul 18, 2025
13ba443
Add simulation analysis and implementation
Zetazzz Jul 18, 2025
db93fa8
fixed signer types and build
Zetazzz Jul 21, 2025
39d4c68
fixed types of base-signer and build
Zetazzz Jul 21, 2025
f90ce6d
fix broadcast for base signer
Zetazzz Jul 21, 2025
02e4c4b
fixed signer config and build
Zetazzz Jul 21, 2025
3f63012
fix wallet with derivations and build
Zetazzz Jul 22, 2025
90fb975
fixed wallet tests and comments
Zetazzz Jul 22, 2025
94f8460
fixed token test
Zetazzz Jul 22, 2025
7f0d66b
add interchainjs and fix build
Zetazzz Jul 23, 2025
dc29240
fix sign method usage
Zetazzz Jul 23, 2025
18b4036
fixed offline signer checking bug in wf
Zetazzz Jul 23, 2025
b70ca2e
add FAST_DEBUG_SETUP_GUIDE
Zetazzz Jul 24, 2025
5552cf6
add hash logic to cosmos wallets
Zetazzz Jul 25, 2025
4778b03
fixed tx parse error
Zetazzz Jul 25, 2025
5e6c3f7
add error handling for get encoder
Zetazzz Jul 25, 2025
e5f3028
fixed broadcast errors
Zetazzz Jul 26, 2025
d2fc6a1
fixed getTx
Zetazzz Jul 26, 2025
5810e5d
minor refactored plugins
Zetazzz Jul 26, 2025
1512adb
add amino test and debug and fix
Zetazzz Jul 26, 2025
7aeb9e4
architecture doc and remove log
Zetazzz Jul 26, 2025
d0be20a
fixed hash and test offline signers
Zetazzz Jul 26, 2025
d909a76
fixed starship tests
Zetazzz Jul 27, 2025
2b849c8
refactored clients
Zetazzz Jul 28, 2025
fe2f7a5
finished wallet and tests
Zetazzz Jul 28, 2025
2276646
finished signing workflow
Zetazzz Jul 29, 2025
fdb9f31
fixed eth starship test
Zetazzz Jul 30, 2025
afa1ac8
add back libs and fix types
Zetazzz Jul 30, 2025
b01e8f5
change pubkey logic
Zetazzz Jul 30, 2025
20f937c
unify starship commands
Zetazzz Jul 30, 2025
9f2e48f
inj eth wallet
Zetazzz Jul 30, 2025
0328957
add default configs
Zetazzz Jul 30, 2025
4165546
add default config to eth
Zetazzz Jul 30, 2025
74ceb7d
fixed inj starship tests in cosmos way
Zetazzz Jul 31, 2025
c42e9f8
apply inj signer config to staking tests
Zetazzz Jul 31, 2025
43ceef2
handle post process of signature
Zetazzz Aug 1, 2025
28d8057
preset inj compact signature format
Zetazzz Aug 1, 2025
8438ad0
fix ethSecp256k1hd wallet
Zetazzz Aug 2, 2025
749a4e7
fixed staking test in inj
openhands-agent Aug 2, 2025
9252c2a
pass inj tests
Zetazzz Aug 2, 2025
a245894
apply helper functions to inj
Zetazzz Aug 2, 2025
264f991
add event starship test
Zetazzz Aug 2, 2025
d470aaf
removed encodeParams and decodeResp
Zetazzz Aug 2, 2025
e689fe9
updated docs
Zetazzz Aug 3, 2025
6c194d2
integrated workflow and architecture guide
Zetazzz Aug 3, 2025
2f69f1c
fix starship README
Zetazzz Aug 3, 2025
43207e4
refine starship test READMEs
Zetazzz Aug 3, 2025
9df7448
remove doc and regen code
Zetazzz Aug 3, 2025
af9a509
remove bank tx from cosmos-types
Zetazzz Aug 3, 2025
b83daf4
fix ethereum starship test errors
Zetazzz Aug 3, 2025
e33ac85
fixed yarn tests
Zetazzz Aug 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 0 additions & 28 deletions .github/workflows/e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,6 @@ on:
workflow_dispatch:

jobs:
interchainjs:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository 📝
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Build Project
run: yarn build

- name: Set Up Starship Infrastructure
id: starship-infra
uses: hyperweb-io/starship-action@0.5.5
with:
config: libs/interchainjs/starship/configs/config.workflow.yaml

- name: Run E2E Tests
run: cd ./libs/interchainjs && yarn starship:test

networks-cosmos:
runs-on: ubuntu-latest

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ lerna-debug.log
.claude
CLAUDE.md

.cert/
.cert/

.augment/
140 changes: 79 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,80 +130,77 @@ npm i @interchainjs/cosmos

## Quick Start

Get a signing client to send the trasactions:
### Using Signers Directly

```ts
import { SigningClient as CosmosSigningClient } from "@interchainjs/cosmos";
Create and use signers for transaction signing and broadcasting:

const signingClient = await CosmosSigningClient.connectWithSigner(
await getRpcEndpoint(),
new DirectGenericOfflineSigner(directSigner),
```typescript
import { DirectSigner } from '@interchainjs/cosmos';
import { Secp256k1HDWallet } from '@interchainjs/cosmos';
import { HDPath } from '@interchainjs/types';

// Create wallet from mnemonic
const wallet = await Secp256k1HDWallet.fromMnemonic(
"your twelve word mnemonic phrase here",
{
registry: [
// as many as possible encoders registered here.
MsgDelegate,
MsgSend,
],
broadcast: {
checkTx: true,
},
derivations: [{
prefix: "cosmos",
hdPath: HDPath.cosmos(0, 0, 0).toString(), // m/44'/118'/0'/0/0
}]
}
);

// sign and broadcast
const result = await signingClient.signAndBroadcast(<MESSAGE>[]);
console.log(result.hash); // the hash of TxRaw
// Create signer
const signer = new DirectSigner(wallet, {
chainId: 'cosmoshub-4',
queryClient: queryClient,
addressPrefix: 'cosmos'
});

// Sign and broadcast transaction
const result = await signer.signAndBroadcast({
messages: [{
typeUrl: '/cosmos.bank.v1beta1.MsgSend',
value: {
fromAddress: 'cosmos1...',
toAddress: 'cosmos1...',
amount: [{ denom: 'uatom', amount: '1000000' }]
}
}],
fee: {
amount: [{ denom: 'uatom', amount: '5000' }],
gas: '200000'
},
memo: 'Transfer via InterchainJS'
});

console.log('Transaction hash:', result.transactionHash);
```

Use the tree shakable helper functions provided by interchainjs or generated by telescope for query or send the transctions:
### Using with External Wallets

```ts
import { SigningClient as CosmosSigningClient } from "@interchainjs/cosmos/signing-client";
import { getBalance } from "interchainjs/cosmos/bank/v1beta1/query.rpc.func";
import { submitProposal } from "interchainjs/cosmos/gov/v1beta1/tx.rpc.func";
For integration with browser wallets like Keplr:

// query to get balance
const { balance } = await getBalance(await getRpcEndpoint(), {
address: directAddress,
denom,
});
```typescript
import { DirectSigner } from '@interchainjs/cosmos';

const signingClient = await CosmosSigningClient.connectWithSigner(
await getRpcEndpoint(),
new DirectGenericOfflineSigner(directSigner),
{
// no registry needed here anymore
// registry: [
// ],
broadcast: {
checkTx: true,
},
}
);
// Get offline signer from Keplr
await window.keplr.enable(chainId);
const offlineSigner = window.keplr.getOfflineSigner(chainId);

// Necessary typeurl and codecs will be registered automatically in the helper functions. Meaning users don't have to register them all at once.
const result = await submitProposal(
signingClient,
directAddress,
{
proposer: directAddress,
initialDeposit: [
{
amount: "1000000",
denom: denom,
},
],
content: {
typeUrl: "/cosmos.gov.v1beta1.TextProposal",
value: TextProposal.encode(contentMsg).finish(),
},
},
fee,
"submit proposal"
);
console.log(result.hash); // the hash of TxRaw
```
// Create signer with offline signer
const signer = new DirectSigner(offlineSigner, {
chainId: 'cosmoshub-4',
queryClient: queryClient,
addressPrefix: 'cosmos'
});

// Use the same signing interface
const result = await signer.signAndBroadcast({
messages: [/* your messages */],
fee: { amount: [{ denom: 'uatom', amount: '5000' }], gas: '200000' }
});
```

### Quick Setup with create-interchain-app

Expand Down Expand Up @@ -247,6 +244,27 @@ Then an authz example website will be created and users can take a look how sign

---

## Developer Documentation

### For Contributors and Network Implementers

- **[Network Implementation Guide](./docs/advanced/network-implementation-guide.md)** - Comprehensive guide for implementing new blockchain network support
- **[Workflow Builder and Plugins Guide](./docs/advanced/workflow-builder-and-plugins.md)** - Plugin-based transaction workflow architecture
- **[Auth vs. Wallet vs. Signer](./docs/advanced/auth-wallet-signer.md)** - Understanding the three-layer architecture
- **[Tutorial](./docs/advanced/tutorial.md)** - Using and extending signers in the InterchainJS ecosystem

### Architecture and Design

InterchainJS follows a modular, three-layer architecture that separates concerns and enables flexible blockchain integration:

1. **Auth Layer**: Cryptographic operations and key management
2. **Wallet Layer**: Account management and address derivation
3. **Signer Layer**: Transaction building, signing, and broadcasting

This separation allows for maximum flexibility while maintaining type safety and consistent interfaces across different blockchain networks.

---

## Interchain JavaScript Stack ⚛️

A unified toolkit for building applications and smart contracts in the Interchain ecosystem
Expand Down
103 changes: 72 additions & 31 deletions docs/advanced/auth-wallet-signer.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,99 @@
# Auth vs. Wallet vs. Signer: A Comparison

This document aims to provide an overview and comparison of `Auth`, `Wallet`, and `Signer`, three types commonly used for encryption and signing purposes in different networks. Each type serves a specific purpose and has its own characteristics and functionalities.
This document provides an overview and comparison of `Auth`, `Wallet`, and `Signer`, three core abstractions used for cryptographic operations and transaction signing in the InterchainJS ecosystem. Each serves a specific purpose in the signing workflow and has distinct characteristics and functionalities.

```mermaid
graph LR
subgraph AuthType[Auth]
ByteAuth --> |privateKey| PrivateKey
PrivateKey --> |sign| SignedTx
OfflineSigner[Hide PrivateKey] --> DocAuth
DocAuth --> |signDoc| SignedTx
subgraph AuthLayer[Auth Layer]
IWallet --> |getAccounts| IAccount[Account]
IWallet --> |signByIndex| Signature
OfflineSigner --> |signDirect/signAmino| SignedDoc
end

Wallet --> |accounts| IAccount[Account]
Wallet --> |toOfflineSigner| OfflineSigner

Signer --> |prefix| Prefix
Signer --> |account| Account
Signer --> |encoders| Encoder
Signer --> |signAndBroadCast| SignAndBroadCast
subgraph SignerLayer[Signer Layer]
IUniSigner --> |getAccounts| AccountData
IUniSigner --> |sign| ISigned
IUniSigner --> |signAndBroadcast| BroadcastResponse
IUniSigner --> |signArbitrary| ICryptoBytes
end

Account --> |auth| Auth
AuthLayer --> SignerLayer
IAccount --> |address/publicKey| SignerLayer

```

## 1. Auth
## 1. Auth Layer

The Auth layer provides the foundational cryptographic capabilities for account management and signing operations. It consists of two main abstractions:

### IWallet Interface

`IWallet` is the primary interface for managing cryptographic accounts and performing low-level signing operations:

- **Account Management**: Provides access to multiple accounts through `getAccounts()` and `getAccountByIndex()`
- **Direct Signing**: Offers `signByIndex()` method to sign arbitrary binary data using a specific account
- **Network Agnostic**: Designed to work across different blockchain networks with configurable address derivation strategies

### OfflineSigner Interface

`OfflineSigner` provides a secure way to sign transactions without exposing private keys:

- **External Wallet Integration**: Designed for integration with external wallets like Keplr, Leap, or hardware wallets
- **Document Signing**: Supports both Direct (protobuf) and Amino (JSON) signing modes through `OfflineDirectSigner` and `OfflineAminoSigner`
- **Privacy Preservation**: Keeps private keys secure within the external wallet while providing signing capabilities

## 2. Wallet Implementations

Wallet implementations provide concrete realizations of the `IWallet` interface, offering HD (Hierarchical Deterministic) key derivation and network-specific address generation:

### Secp256k1HDWallet

The primary wallet implementation for secp256k1 cryptography:

- **HD Key Derivation**: Supports BIP-32/BIP-44 hierarchical deterministic key derivation from mnemonic phrases
- **Multi-Account Support**: Can manage multiple accounts with different derivation paths
- **Network Compatibility**: Works across Cosmos, Ethereum, and Injective networks with appropriate address strategies
- **Offline Signer Conversion**: Can be converted to `OfflineDirectSigner` or `OfflineAminoSigner` for external wallet compatibility

`Auth` is a common implementation of an encryption algorithm that can be utilized across different networks. It provides a signing method to sign binary data. The primary features and characteristics of `Auth` are as follows:
### Network-Specific Variants

- **Encryption Algorithm**: `Auth` implements an encryption algorithm that is compatible and usable across various networks.
- **Cosmos**: `Secp256k1HDWallet` with bech32 address encoding
- **Ethereum**: `Secp256k1HDWallet` with keccak256 hashing and hex address format
- **Injective**: `EthSecp256k1HDWallet` with Ethereum-style addresses but Cosmos transaction format

- **Signing Binary Data**: `Auth` offers a method to sign binary data, which can be used for verifying the integrity and authenticity of the data.
## 3. Signer Layer

- **Network Agnostic**: Auth is designed to work with different networks, making it a versatile solution for encryption and signing needs.
The Signer layer provides the highest-level abstraction for transaction signing and broadcasting, implementing the `IUniSigner` interface. Signers can be constructed from either `IWallet` implementations or `OfflineSigner` interfaces.

## 2. Wallet
### IUniSigner Interface

`Wallet` is a wrapper built upon `Auth`, providing additional functionalities and convenience, particularly for Web3 usage. `Wallet` extends the capabilities of `Auth` and introduces the following aspects:
The universal signer interface provides a consistent API across all blockchain networks:

- **Signing Network and Document**: In addition to signing binary data, `Wallet` provides a signing method specifically designed for signing network-related information and sign mode specified documents.
- **Account Management**: `getAccounts()` returns account information including addresses and public keys
- **Transaction Workflow**: `sign()` creates signed transactions, `broadcast()` submits them to the network, and `signAndBroadcast()` combines both operations
- **Arbitrary Signing**: `signArbitrary()` signs raw binary data for authentication purposes
- **Network Abstraction**: Generic type parameters allow network-specific customization while maintaining a unified interface

- **Web3 Integration**: `Wallet` is tailored for Web3 usage, making it compatible with blockchain and decentralized applications.
### Network-Specific Implementations

- **Enhanced Functionality**: `Wallet` encompasses the features of `Auth` while incorporating additional functionalities to facilitate secure interactions with Web3 wallets.
- **Cosmos Signers**: `DirectSigner` and `AminoSigner` for protobuf and JSON signing modes
- **Ethereum Signers**: `LegacySigner` and `Eip1559Signer` for different transaction types
- **Injective Signers**: Cosmos-compatible signers with Ethereum-style address derivation

## 3. Signer
### Construction Patterns

`Signer` is a class that can be constructed from `Auth` or `Wallet`. It focuses on providing a signing method specifically for directly signing human-readable messages. Key aspects of `Signer` include:
Signers can be constructed in multiple ways:

- **Signing Human-Readable Messages**: `Signer` offers a dedicated signing method for signing messages that are in a human-readable format, such as plain text or structured data.
1. **From IWallet**: Direct construction with full private key access
2. **From OfflineSigner**: Construction for external wallet integration
3. **Configuration-based**: Using network-specific configuration objects

- **Flexible Construction**: `Signer` can be constructed using either `Auth` or `Wallet`, allowing users to choose their preferred underlying implementation based on their specific requirements.
## Summary

- **Message-Level Security**: `Signer` emphasizes the signing of human-readable messages, making it suitable for use cases where secure communication and message integrity are essential.
The three-layer architecture provides clear separation of concerns:

In summary, `Auth` serves as a fundamental implementation of an encryption algorithm, providing a signing method for binary data. `Wallet`, built upon `Auth`, extends its capabilities by introducing network and document-specific signing methods, tailored for Web3 usage. `Signer`, the top-level layer, contains the code for structured data signing and focuses on dedicated methods for directly signing human-readable messages, which offers flexibility and message-level security.
- **Auth Layer**: Foundational cryptographic operations and account management
- **Wallet Layer**: HD key derivation and network-specific address generation
- **Signer Layer**: High-level transaction signing and broadcasting with network abstraction

The hierarchical relationship between `Auth`, `Wallet`, and `Signer` positions Auth as the foundation, Wallet as the middle layer, and Signer as the top layer with the highest-level functionality for structured data signing. However, the specific choice among `Auth`, `Wallet`, or `Signer` depends on specific requirements and use cases, ensuring the appropriate level of encryption, signing, and security for various network-related operations.
This design allows developers to choose the appropriate abstraction level based on their security requirements, from low-level cryptographic control to high-level transaction management, while maintaining compatibility across different blockchain networks.
Loading
Loading