Skip to content

Commit

Permalink
Max/tssdk docs maintenance (#5364)
Browse files Browse the repository at this point in the history
* add temp warning
  • Loading branch information
mfahampshire authored Jan 20, 2025
1 parent 13cfa55 commit 8e05386
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Callout } from 'nextra/components'

# Cosmos Kit

<Callout type="warning">
The Typescript SDK is currently undergoing maintenance: a network upgrade elsewhere has temporarily caused a problem. These docs are likely to change after we upgrade the SDK.
</Callout>

The wonderful people of Cosmology have made some [fantastic components](https://cosmoskit.com/) that can be used with
Nym. These include:

Expand All @@ -17,7 +23,7 @@ npm create vite@latest
During the environment setup, choose React and subsequently opt for Typescript if you want your application to function smoothly following this tutorial. Next, navigate to your application directory and run the following commands:
```bash
cd < YOUR_APP >
npm i
npm i
npm run dev
```

Expand Down Expand Up @@ -57,7 +63,7 @@ export default defineConfig({
Your components have to be wrapped into a [ChainProvider](https://docs.cosmoskit.com/chain-provider),
in order to use the `useChain('nyx')` hook. The nyx chain is provided in the 'chain-registry' NPM package by default.

Now, go to the `src` folder and open your `App.tsx` file to replace all the code with the following, which will allow you to connect and disconnect a Ledger or Keplr wallet to Nyx:
Now, go to the `src` folder and open your `App.tsx` file to replace all the code with the following, which will allow you to connect and disconnect a Ledger or Keplr wallet to Nyx:

```ts
import "./App.css";
Expand All @@ -68,7 +74,7 @@ import { wallets as ledger } from '@cosmos-kit/ledger';
import { wallets as keplr } from '@cosmos-kit/keplr';
import { AminoMsg, makeSignDoc } from '@cosmjs/amino';
import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx';

export const getDoc = (address: string) => {
const chainId = 'nyx';
const msg: AminoMsg = {
Expand All @@ -89,28 +95,28 @@ export const getDoc = (address: string) => {
const doc = makeSignDoc([msg], fee, chainId, memo, accountNumber, sequence);
return doc
};

function MyComponent() {
const {wallet, address, connect, disconnect, getOfflineSignerAmino } =
useChain('nyx');

React.useEffect(() => {
connect();
disconnect();
}, []);

const sign = async () => {
if (!address) return
const doc = getDoc(address);
return getOfflineSignerAmino().signAmino(address, doc);
};

return (
<div>
<div>
<div>
{wallet &&
<div>
<div>Connected to {wallet?.prettyName} </div>
{wallet &&
<div>
<div>Connected to {wallet?.prettyName} </div>
<div>Address: <code>{address}</code></div>
</div>}
</div>
Expand All @@ -126,7 +132,7 @@ function MyComponent() {
</div>
);
}

export default function App() {
const assetsFixedUp = React.useMemo(() => {
const nyx = assets.find((a) => a.chain_name === 'nyx');
Expand All @@ -139,7 +145,7 @@ export default function App() {
}
return assets;
}, [assets]);

return (
<ChainProvider
chains={[chains.find((c) => c.chain_id === 'nyx')!]}
Expand All @@ -149,10 +155,10 @@ export default function App() {
preferredSignType: () => 'amino',
}}
>

<MyComponent/>
</ChainProvider>

)
}
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Callout } from 'nextra/components';

# `mixFetch`

<Callout type="warning">
The Typescript SDK is currently undergoing maintenance: a network upgrade elsewhere has temporarily caused a problem. These docs are likely to change after we upgrade the SDK.
</Callout>
An easy way to secure parts or all of your web app is to replace calls to [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) with `mixFetch`:

MixFetch works the same as vanilla `fetch` as it's a proxied wrapper around the original function.
Expand Down Expand Up @@ -35,9 +37,9 @@ curl -X 'GET' \
import type { SetupMixFetchOps } from '@nymproject/mix-fetch';

const mixFetchOptions: SetupMixFetchOps = {
preferredGateway: '6Gb7ftQdKveMjPyrxDXeAtfYAX7Zg5mVZHtnRC5MmZ1B', // with WSS
preferredGateway: '23A7CSaBSA2L67PWuFTPXUnYrCdyVcB7ATYsjUsfdftb', // with WSS
preferredNetworkRequester:
'8rRGWy54oC8drFL9DepMegBt2DLrsqQwCoHMXt9nsnTo.2XjCPVbb4FpQ9hNRcXwb9mTzEAVVk1zf1tcch3wdtNEA@6Gb7ftQdKveMjPyrxDXeAtfYAX7Zg5mVZHtnRC5MmZ1B',
'HuNL1pFprNSKW6jdqppibXP5KNKCNJxDh7ivpYcoULN9.C62NahRTUf6kqpNtDVHXoVriQr6yyaU5LtxdgpbsGrtA@23A7CSaBSA2L67PWuFTPXUnYrCdyVcB7ATYsjUsfdftb',
mixFetchOverride: {
requestTimeoutMs: 60_000,
},
Expand Down Expand Up @@ -90,9 +92,9 @@ import { mixFetch, SetupMixFetchOps } from '@nymproject/mix-fetch-full-fat';
import React from 'react';

const mixFetchOptions: SetupMixFetchOps = {
preferredGateway: '6Gb7ftQdKveMjPyrxDXeAtfYAX7Zg5mVZHtnRC5MmZ1B', // with WSS
preferredGateway: '23A7CSaBSA2L67PWuFTPXUnYrCdyVcB7ATYsjUsfdftb', // with WSS
preferredNetworkRequester:
'8rRGWy54oC8drFL9DepMegBt2DLrsqQwCoHMXt9nsnTo.2XjCPVbb4FpQ9hNRcXwb9mTzEAVVk1zf1tcch3wdtNEA@6Gb7ftQdKveMjPyrxDXeAtfYAX7Zg5mVZHtnRC5MmZ1B',
'HuNL1pFprNSKW6jdqppibXP5KNKCNJxDh7ivpYcoULN9.C62NahRTUf6kqpNtDVHXoVriQr6yyaU5LtxdgpbsGrtA@23A7CSaBSA2L67PWuFTPXUnYrCdyVcB7ATYsjUsfdftb',
mixFetchOverride: {
requestTimeoutMs: 60_000,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Callout } from 'nextra/components'

# Mixnet Client

<Callout type="warning">
The Typescript SDK is currently undergoing maintenance: a network upgrade elsewhere has temporarily caused a problem. These docs are likely to change after we upgrade the SDK.
</Callout>
As you know by now, in order to send or receive messages over the mixnet, you'll need to use the [`SDK Client`](https://www.npmjs.com/package/@nymproject/sdk), which will allow you to create apps that can use the Nym mixnet and Coconut credentials.

This client is message based - it can only send a one-way message to another client's address.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Callout } from 'nextra/components'

# Nym Smart Contract Clients

<Callout type="warning">
The Typescript SDK is currently undergoing maintenance: a network upgrade elsewhere has temporarily caused a problem. These docs are likely to change after we upgrade the SDK.
</Callout>
As previously mentioned, to query or execute on any of the Nym contracts, you'll need to use one of the [`Contract Clients`](https://www.npmjs.com/package/@nymproject/contract-clients), which contains read-only query and signing clients for all of Nym's smart contracts.

##### Contract Clients list
Expand Down Expand Up @@ -29,14 +31,14 @@ npm create vite@latest
During the environment setup, choose React and subsequently opt for Typescript if you want your application to function smoothly following this tutorial. Next, navigate to your application directory and run the following commands:
```bash
cd < YOUR_APP >
npm i
npm i
npm run dev
```

##### Installation
Install the packages and their dependencies if you don't already have them:
```bash
npm install @nymproject/contract-clients @cosmjs/cosmwasm-stargate
npm install @nymproject/contract-clients @cosmjs/cosmwasm-stargate
```

## Query clients
Expand Down Expand Up @@ -143,7 +145,7 @@ import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { GasPrice } from "@cosmjs/stargate";
import { settings } from "./settings";

export default function Exec() {
let signer: DirectSecp256k1HdWallet;
let signerMixnetClient: any;
Expand All @@ -153,7 +155,7 @@ export default function Exec() {
let nodeAddress: string;
let amountToSend: string;
let delegations: any;

async function ExecuteOnNyx() {
// Cosmos client
signer = await DirectSecp256k1HdWallet.fromMnemonic(settings.mnemonic, {
Expand All @@ -168,7 +170,7 @@ export default function Exec() {
);
// Save globally
cosmWasmSigningClient = cosmWasmClient;

// Nym client
const mixnetClient = new contracts.Mixnet.MixnetClient(
cosmWasmSigningClient,
Expand All @@ -177,9 +179,9 @@ export default function Exec() {
);
// Save globally
signerMixnetClient = mixnetClient;

}

// Get delegations
const getDelegations = async () => {
if (!signerMixnetClient) {
Expand All @@ -190,7 +192,7 @@ export default function Exec() {
});
delegations = delegationsObject;
};

// Make delegation
const doDelegation = async () => {
if (!signerMixnetClient) {
Expand All @@ -204,7 +206,7 @@ export default function Exec() {
);
console.log(res);
};

// Undelegate all
const doUndelegateAll = async () => {
for (const delegation of delegations.delegations) {
Expand All @@ -214,7 +216,7 @@ export default function Exec() {
);
}
};

// Sending tokens
const doSendTokens = async () => {
const memo = "test sending tokens";
Expand All @@ -227,10 +229,10 @@ export default function Exec() {
);
console.log(res);
};

ExecuteOnNyx();
setTimeout(() => getDelegations(), 1000);

return (
<div>
<p>Exec</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import "@interchain-ui/react/styles"
import { CosmosKit } from "../../../../components/cosmos-kit";
import { Callout } from 'nextra/components'
import FormattedCosmoskitExampleCode from '../../../../code-examples/sdk/typescript/cosmoskit-example-code.mdx';

# Cosmos Kit

import { Callout } from 'nextra/components'

<Callout type="warning">
The Typescript SDK is currently undergoing maintenance: a network upgrade elsewhere has temporarily caused a problem. These docs are likely to change after we upgrade the SDK.
</Callout>

Below is an example that uses [CosmosKit](https://cosmoskit.com/) to connect and sign a fake transaction with your [Keplr wallet](https://www.keplr.app/) or
[Ledger hardware wallet](https://www.ledger.com/) to this page:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import Box from '@mui/material/Box';
import FormattedMixFetchExampleCode from '../../../../code-examples/sdk/typescript/mixfetch-example-code.mdx';
import { Callout } from 'nextra/components'

<Callout type="warning">
The Typescript SDK is currently undergoing maintenance: a network upgrade elsewhere has temporarily caused a problem. These docs are likely to change after we upgrade the SDK.
</Callout>

<Callout type="info" emoji="ℹ️">
Right now Gateways are not required to run a Secure Websocket (WSS) listener, so only a subset of nodes running in Gateway mode have configured their nodes to do so.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import { Mixnodes } from '../../../../components/mixnodes';
import Box from '@mui/material/Box';
import FormattedExampleCode from '../../../../code-examples/sdk/typescript/mixnodes-example-code.mdx';
import { Callout } from 'nextra/components'

<Callout type="warning">
The Typescript SDK is currently undergoing maintenance: a network upgrade elsewhere has temporarily caused a problem. These docs are likely to change after we upgrade the SDK.
</Callout>

The Nym Mixnet contract keeps a directory of all mixnodes that can be used to mix traffic.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { Traffic } from '../../../../components/traffic';
import Box from '@mui/material/Box';
import FormattedTrafficExampleCode from '../../../../code-examples/sdk/typescript/traffic-example-code.mdx';

<Callout type="warning">
The Typescript SDK is currently undergoing maintenance: a network upgrade elsewhere has temporarily caused a problem. These docs are likely to change after we upgrade the SDK.
</Callout>

Use this tool to experiment with the mixnet: send and receive messages!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import FormattedWalletConnectCode from '../../../../code-examples/sdk/typescript
import FormattedWalletSendTokensCode from '../../../../code-examples/sdk/typescript/wallet-sendTokens-code.mdx';
import FormattedWalletDelegationsCode from '../../../../code-examples/sdk/typescript/wallet-delegations-code.mdx';


import { Callout } from 'nextra/components'

<Callout type="warning">
The Typescript SDK is currently undergoing maintenance: a network upgrade elsewhere has temporarily caused a problem. These docs are likely to change after we upgrade the SDK.
</Callout>

Here's a small wallet example using testnet for you to test out!

<WalletContextProvider>
Expand Down

0 comments on commit 8e05386

Please sign in to comment.