Sol.College

Full lesson

rango-client

Rango Exchange Widget & Wallets Library

Original
rango-exchange/rango-client
SuperStack fork
Blockchains/rango-client @ e55d865
Stars
1,124
Last push (original)
2026-11-02
Languages
TypeScript, JavaScript, HTML, CSS, Shell
Detected stack
Next.jsweb3.js
Categories
DeFiWallets & Identity
Licence
Apache-2.0
Homepage
https://rango.exchange/widget

Architecture

1438 source files. By extension: .ts ×1027, .tsx ×401, .js ×10.

Top-level directorySource files
widget904
wallets377
queue-manager85
signers25
examples21
logging13
blockchains5
(root)4

Dapp: deploying

This fork is queued for its own live dapp on Sol.College, with a Devnet/Mainnet switch. It appears here, at /dapps/rango-client/, once it is deployed and checked on devnet. Until then, run it locally with the commands below.

Key code, explained

Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.

rango-exchange/rango-client · wallets/provider-walletconnect-2/src/signers/evm.ts L25–48 @ e55d865 · Apache-2.0 · original
}; class EVMSigner implements GenericSigner<EvmTransaction> {  private client: ISignClient;  private getSession: SessionGetter;   constructor(client: ISignClient, getSession: SessionGetter) {    this.client = client;    this.getSession = getSession;  }   private get session(): SessionTypes.Struct {    const session = this.getSession();    if (!session) {      throw new Error('EVM WalletConnect session is not available.');    }    return session;  }   /**   * Map Rango's EvmTransaction to WalletConnect eth_sendTransaction params.   *   * Unlike DefaultEvmSigner.buildTx (ethers TransactionRequest with gasLimit +   * decimal fee strings), WC sends params raw over the relay. Wallets like
  1. Line 27 class EVMSigner implements GenericSigner<EvmTransaction> {: Requires this account to have signed the transaction.
  2. Line 45 * Map Rango's EvmTransaction to WalletConnect eth_sendTransaction params.: Submits the signed transaction to the cluster.
rango-exchange/rango-client · wallets/provider-ledger-wallet/src/signers/evm.ts L73–96 @ e55d865 · Apache-2.0 · original
     * Legacy path: Ledger still requires maxFee* to skip re-estimation, so it     * will overwrite gas/fees with its own EIP-1559 estimate. We only forward     * gasPrice for wallets that honor it; do not expect Rango's gasLimit to     * stick on this path.     */    params.gasPrice = toHexQuantity(tx.gasPrice);  }  return params;}; /* * Implement GenericSigner so signAndSendTx can return only `{ hash }` — * Ledger's eth_sendTransaction never yields an ethers TransactionResponse. * Delegate personal_sign / eth_signTypedData_v4 to DefaultEvmSigner (supported * by Ledger). Do not use its signAndSendTx: ethers then polls * eth_getTransactionByHash, which Ledger does not support. */export class CustomEvmSigner implements GenericSigner<EvmTransaction> {  private defaultEvmSigner: DefaultEvmSigner;   constructor() {    /*     * Provider comes from the EIP-6963 announce stashed in ledgerProvider     * (getSigners runs after connect, so it should already be set).
  1. Line 85 * Ledger's eth_sendTransaction never yields an ethers TransactionResponse.: Submits the signed transaction to the cluster.
  2. Line 90 export class CustomEvmSigner implements GenericSigner<EvmTransaction> {: Requires this account to have signed the transaction.
rango-exchange/rango-client · wallets/provider-tonconnect/src/signers/ton.ts L13–36 @ e55d865 · Apache-2.0 · original
 export class CustomTonSigner implements GenericSigner<TonTransaction> {  private provider: TonConnectUI;   constructor(provider: TonConnectUI) {    this.provider = provider;  }   async signMessage(): Promise<string> {    throw SignerError.UnimplementedError('signMessage');  }   async signAndSendTx(tx: TonTransaction): Promise<{ hash: string }> {    const transaction = DefaultTonSigner.buildTx(tx);    const { valid_until, network, ...restTransactionFields } = transaction;     const result = await this.provider.sendTransaction({      ...restTransactionFields,      validUntil: valid_until,      network: NETWORKS[network],    });     const hash = Cell.fromBase64(result.boc).hash().toString('hex');    return { hash };
  1. Line 14 export class CustomTonSigner implements GenericSigner<TonTransaction> {: Requires this account to have signed the transaction.
  2. Line 29 const result = await this.provider.sendTransaction({: Submits the signed transaction to the cluster.

How to run, build and test

These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.

DirectoryCommandRuns
.npm run buildnx affected --target=build --parallel=5
.npm run testvitest
.npm run lintnx run-many --target=lint
.npm run deploynode ./scripts/deploy/command.mjs
logging/corenpm run buildyarn run rangutopia library build
logging/corenpm run linteslint "**/*.{ts,tsx}"
logging/sentrynpm run buildyarn run rangutopia library build
logging/sentrynpm run linteslint "**/*.{ts,tsx}"
logging/consolenpm run buildyarn run rangutopia library build
logging/consolenpm run linteslint "**/*.{ts,tsx}"
logging/subscribernpm run buildyarn run rangutopia library build
logging/subscribernpm run linteslint "**/*.{ts,tsx}"
logging/typesnpm run buildyarn run rangutopia library build
logging/typesnpm run linteslint "**/*.{ts,tsx}"
examples/react-app-rewired-tsnpm run startexport NODE_OPTIONS='--max_old_space_size=8192'; react-app-rewired start
examples/react-app-rewired-tsnpm run buildreact-app-rewired build

What you could build from it

Used in lessons