Compare commits

...

6 Commits

Author SHA1 Message Date
mfahampshire 25b45a911c push to remote for cleanbuild 2025-01-24 11:37:55 +01:00
mfahampshire ffc72feb12 add temp warning 2025-01-17 15:24:25 +01:00
mfahampshire 0793133c95 Merge branch 'develop' of github.com:nymtech/nym into develop 2025-01-16 14:13:32 +01:00
mfahampshire b1d10b41a4 Merge branch 'develop' of github.com:nymtech/nym into develop 2025-01-15 13:12:31 +01:00
mfahampshire b33708bbe6 Merge branch 'develop' of github.com:nymtech/nym into develop 2025-01-14 23:52:00 +01:00
mfahampshire eea8ee589f removed old todos 2025-01-14 15:28:05 +01:00
14 changed files with 5006 additions and 33123 deletions
+3 -3
View File
@@ -37,9 +37,9 @@
"@mui/material": "^5.14.8", "@mui/material": "^5.14.8",
"@nextui-org/accordion": "^2.0.40", "@nextui-org/accordion": "^2.0.40",
"@nextui-org/react": "^2.4.8", "@nextui-org/react": "^2.4.8",
"@nymproject/contract-clients": ">=1.2.4-rc.2 || ^1", "@nymproject/contract-clients": ">=1.4.0-rc.0 || ^1",
"@nymproject/mix-fetch-full-fat": ">=1.2.4-rc.2 || ^1", "@nymproject/mix-fetch-full-fat": ">=1.4.0-rc.0 || ^1",
"@nymproject/sdk-full-fat": ">=1.2.4-rc.2 || ^1", "@nymproject/sdk-full-fat": ">=1.4.0-rc.0 || ^1",
"@redocly/cli": "^1.25.15", "@redocly/cli": "^1.25.15",
"@types/mdx": "^2.0.13", "@types/mdx": "^2.0.13",
"chain-registry": "^1.19.0", "chain-registry": "^1.19.0",
@@ -2,6 +2,3 @@
The Rust SDK allows developers building applications in Rust to import and interact with Nym clients as they would any other dependency, instead of running the client as a separate process on their machine. The Rust SDK allows developers building applications in Rust to import and interact with Nym clients as they would any other dependency, instead of running the client as a separate process on their machine.
Check the [development status](./rust/development-status) page to see the various modules that make up the SDK, and the [FFI](./rust/ffi) page for Go/C++ developers. Check the [development status](./rust/development-status) page to see the various modules that make up the SDK, and the [FFI](./rust/ffi) page for Go/C++ developers.
### Generate Crate Docs
In order to generate the crate docs run `cargo doc --open` from `nym/sdk/rust/nym-sdk/`
@@ -1,5 +1,11 @@
import { Callout } from 'nextra/components'
# Cosmos Kit # 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 The wonderful people of Cosmology have made some [fantastic components](https://cosmoskit.com/) that can be used with
Nym. These include: Nym. These include:
@@ -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: 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 ```bash
cd < YOUR_APP > cd < YOUR_APP >
npm i npm i
npm run dev npm run dev
``` ```
@@ -57,7 +63,7 @@ export default defineConfig({
Your components have to be wrapped into a [ChainProvider](https://docs.cosmoskit.com/chain-provider), 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. 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 ```ts
import "./App.css"; import "./App.css";
@@ -68,7 +74,7 @@ import { wallets as ledger } from '@cosmos-kit/ledger';
import { wallets as keplr } from '@cosmos-kit/keplr'; import { wallets as keplr } from '@cosmos-kit/keplr';
import { AminoMsg, makeSignDoc } from '@cosmjs/amino'; import { AminoMsg, makeSignDoc } from '@cosmjs/amino';
import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx'; import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx';
export const getDoc = (address: string) => { export const getDoc = (address: string) => {
const chainId = 'nyx'; const chainId = 'nyx';
const msg: AminoMsg = { const msg: AminoMsg = {
@@ -89,28 +95,28 @@ export const getDoc = (address: string) => {
const doc = makeSignDoc([msg], fee, chainId, memo, accountNumber, sequence); const doc = makeSignDoc([msg], fee, chainId, memo, accountNumber, sequence);
return doc return doc
}; };
function MyComponent() { function MyComponent() {
const {wallet, address, connect, disconnect, getOfflineSignerAmino } = const {wallet, address, connect, disconnect, getOfflineSignerAmino } =
useChain('nyx'); useChain('nyx');
React.useEffect(() => { React.useEffect(() => {
connect(); connect();
disconnect(); disconnect();
}, []); }, []);
const sign = async () => { const sign = async () => {
if (!address) return if (!address) return
const doc = getDoc(address); const doc = getDoc(address);
return getOfflineSignerAmino().signAmino(address, doc); return getOfflineSignerAmino().signAmino(address, doc);
}; };
return ( return (
<div> <div>
<div> <div>
{wallet && {wallet &&
<div> <div>
<div>Connected to {wallet?.prettyName} </div> <div>Connected to {wallet?.prettyName} </div>
<div>Address: <code>{address}</code></div> <div>Address: <code>{address}</code></div>
</div>} </div>}
</div> </div>
@@ -126,7 +132,7 @@ function MyComponent() {
</div> </div>
); );
} }
export default function App() { export default function App() {
const assetsFixedUp = React.useMemo(() => { const assetsFixedUp = React.useMemo(() => {
const nyx = assets.find((a) => a.chain_name === 'nyx'); const nyx = assets.find((a) => a.chain_name === 'nyx');
@@ -139,7 +145,7 @@ export default function App() {
} }
return assets; return assets;
}, [assets]); }, [assets]);
return ( return (
<ChainProvider <ChainProvider
chains={[chains.find((c) => c.chain_id === 'nyx')!]} chains={[chains.find((c) => c.chain_id === 'nyx')!]}
@@ -149,10 +155,10 @@ export default function App() {
preferredSignType: () => 'amino', preferredSignType: () => 'amino',
}} }}
> >
<MyComponent/> <MyComponent/>
</ChainProvider> </ChainProvider>
) )
} }
``` ```
@@ -1,7 +1,9 @@
import { Callout } from 'nextra/components'; import { Callout } from 'nextra/components';
# `mixFetch` # `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`: 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. MixFetch works the same as vanilla `fetch` as it's a proxied wrapper around the original function.
@@ -35,9 +37,9 @@ curl -X 'GET' \
import type { SetupMixFetchOps } from '@nymproject/mix-fetch'; import type { SetupMixFetchOps } from '@nymproject/mix-fetch';
const mixFetchOptions: SetupMixFetchOps = { const mixFetchOptions: SetupMixFetchOps = {
preferredGateway: '6Gb7ftQdKveMjPyrxDXeAtfYAX7Zg5mVZHtnRC5MmZ1B', // with WSS preferredGateway: '23A7CSaBSA2L67PWuFTPXUnYrCdyVcB7ATYsjUsfdftb', // with WSS
preferredNetworkRequester: preferredNetworkRequester:
'8rRGWy54oC8drFL9DepMegBt2DLrsqQwCoHMXt9nsnTo.2XjCPVbb4FpQ9hNRcXwb9mTzEAVVk1zf1tcch3wdtNEA@6Gb7ftQdKveMjPyrxDXeAtfYAX7Zg5mVZHtnRC5MmZ1B', 'HuNL1pFprNSKW6jdqppibXP5KNKCNJxDh7ivpYcoULN9.C62NahRTUf6kqpNtDVHXoVriQr6yyaU5LtxdgpbsGrtA@23A7CSaBSA2L67PWuFTPXUnYrCdyVcB7ATYsjUsfdftb',
mixFetchOverride: { mixFetchOverride: {
requestTimeoutMs: 60_000, requestTimeoutMs: 60_000,
}, },
@@ -90,9 +92,9 @@ import { mixFetch, SetupMixFetchOps } from '@nymproject/mix-fetch-full-fat';
import React from 'react'; import React from 'react';
const mixFetchOptions: SetupMixFetchOps = { const mixFetchOptions: SetupMixFetchOps = {
preferredGateway: '6Gb7ftQdKveMjPyrxDXeAtfYAX7Zg5mVZHtnRC5MmZ1B', // with WSS preferredGateway: '23A7CSaBSA2L67PWuFTPXUnYrCdyVcB7ATYsjUsfdftb', // with WSS
preferredNetworkRequester: preferredNetworkRequester:
'8rRGWy54oC8drFL9DepMegBt2DLrsqQwCoHMXt9nsnTo.2XjCPVbb4FpQ9hNRcXwb9mTzEAVVk1zf1tcch3wdtNEA@6Gb7ftQdKveMjPyrxDXeAtfYAX7Zg5mVZHtnRC5MmZ1B', 'HuNL1pFprNSKW6jdqppibXP5KNKCNJxDh7ivpYcoULN9.C62NahRTUf6kqpNtDVHXoVriQr6yyaU5LtxdgpbsGrtA@23A7CSaBSA2L67PWuFTPXUnYrCdyVcB7ATYsjUsfdftb',
mixFetchOverride: { mixFetchOverride: {
requestTimeoutMs: 60_000, requestTimeoutMs: 60_000,
}, },
@@ -1,7 +1,9 @@
import { Callout } from 'nextra/components' import { Callout } from 'nextra/components'
# Mixnet Client # 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. 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. This client is message based - it can only send a one-way message to another client's address.
@@ -1,7 +1,9 @@
import { Callout } from 'nextra/components' import { Callout } from 'nextra/components'
# Nym Smart Contract Clients # 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. 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 ##### Contract Clients list
@@ -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: 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 ```bash
cd < YOUR_APP > cd < YOUR_APP >
npm i npm i
npm run dev npm run dev
``` ```
##### Installation ##### Installation
Install the packages and their dependencies if you don't already have them: Install the packages and their dependencies if you don't already have them:
```bash ```bash
npm install @nymproject/contract-clients @cosmjs/cosmwasm-stargate npm install @nymproject/contract-clients @cosmjs/cosmwasm-stargate
``` ```
## Query clients ## Query clients
@@ -143,7 +145,7 @@ import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { GasPrice } from "@cosmjs/stargate"; import { GasPrice } from "@cosmjs/stargate";
import { settings } from "./settings"; import { settings } from "./settings";
export default function Exec() { export default function Exec() {
let signer: DirectSecp256k1HdWallet; let signer: DirectSecp256k1HdWallet;
let signerMixnetClient: any; let signerMixnetClient: any;
@@ -153,7 +155,7 @@ export default function Exec() {
let nodeAddress: string; let nodeAddress: string;
let amountToSend: string; let amountToSend: string;
let delegations: any; let delegations: any;
async function ExecuteOnNyx() { async function ExecuteOnNyx() {
// Cosmos client // Cosmos client
signer = await DirectSecp256k1HdWallet.fromMnemonic(settings.mnemonic, { signer = await DirectSecp256k1HdWallet.fromMnemonic(settings.mnemonic, {
@@ -168,7 +170,7 @@ export default function Exec() {
); );
// Save globally // Save globally
cosmWasmSigningClient = cosmWasmClient; cosmWasmSigningClient = cosmWasmClient;
// Nym client // Nym client
const mixnetClient = new contracts.Mixnet.MixnetClient( const mixnetClient = new contracts.Mixnet.MixnetClient(
cosmWasmSigningClient, cosmWasmSigningClient,
@@ -177,9 +179,9 @@ export default function Exec() {
); );
// Save globally // Save globally
signerMixnetClient = mixnetClient; signerMixnetClient = mixnetClient;
} }
// Get delegations // Get delegations
const getDelegations = async () => { const getDelegations = async () => {
if (!signerMixnetClient) { if (!signerMixnetClient) {
@@ -190,7 +192,7 @@ export default function Exec() {
}); });
delegations = delegationsObject; delegations = delegationsObject;
}; };
// Make delegation // Make delegation
const doDelegation = async () => { const doDelegation = async () => {
if (!signerMixnetClient) { if (!signerMixnetClient) {
@@ -204,7 +206,7 @@ export default function Exec() {
); );
console.log(res); console.log(res);
}; };
// Undelegate all // Undelegate all
const doUndelegateAll = async () => { const doUndelegateAll = async () => {
for (const delegation of delegations.delegations) { for (const delegation of delegations.delegations) {
@@ -214,7 +216,7 @@ export default function Exec() {
); );
} }
}; };
// Sending tokens // Sending tokens
const doSendTokens = async () => { const doSendTokens = async () => {
const memo = "test sending tokens"; const memo = "test sending tokens";
@@ -227,10 +229,10 @@ export default function Exec() {
); );
console.log(res); console.log(res);
}; };
ExecuteOnNyx(); ExecuteOnNyx();
setTimeout(() => getDelegations(), 1000); setTimeout(() => getDelegations(), 1000);
return ( return (
<div> <div>
<p>Exec</p> <p>Exec</p>
@@ -1,10 +1,15 @@
import "@interchain-ui/react/styles" import "@interchain-ui/react/styles"
import { CosmosKit } from "../../../../components/cosmos-kit"; import { CosmosKit } from "../../../../components/cosmos-kit";
import { Callout } from 'nextra/components'
import FormattedCosmoskitExampleCode from '../../../../code-examples/sdk/typescript/cosmoskit-example-code.mdx'; import FormattedCosmoskitExampleCode from '../../../../code-examples/sdk/typescript/cosmoskit-example-code.mdx';
# Cosmos Kit # 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 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: [Ledger hardware wallet](https://www.ledger.com/) to this page:
@@ -5,6 +5,10 @@ import Box from '@mui/material/Box';
import FormattedMixFetchExampleCode from '../../../../code-examples/sdk/typescript/mixfetch-example-code.mdx'; import FormattedMixFetchExampleCode from '../../../../code-examples/sdk/typescript/mixfetch-example-code.mdx';
import { Callout } from 'nextra/components' 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="️"> <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. 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.
@@ -3,6 +3,11 @@
import { Mixnodes } from '../../../../components/mixnodes'; import { Mixnodes } from '../../../../components/mixnodes';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import FormattedExampleCode from '../../../../code-examples/sdk/typescript/mixnodes-example-code.mdx'; 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. The Nym Mixnet contract keeps a directory of all mixnodes that can be used to mix traffic.
@@ -4,6 +4,9 @@ import { Traffic } from '../../../../components/traffic';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import FormattedTrafficExampleCode from '../../../../code-examples/sdk/typescript/traffic-example-code.mdx'; 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! Use this tool to experiment with the mixnet: send and receive messages!
@@ -10,6 +10,13 @@ import FormattedWalletConnectCode from '../../../../code-examples/sdk/typescript
import FormattedWalletSendTokensCode from '../../../../code-examples/sdk/typescript/wallet-sendTokens-code.mdx'; import FormattedWalletSendTokensCode from '../../../../code-examples/sdk/typescript/wallet-sendTokens-code.mdx';
import FormattedWalletDelegationsCode from '../../../../code-examples/sdk/typescript/wallet-delegations-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! Here's a small wallet example using testnet for you to test out!
<WalletContextProvider> <WalletContextProvider>
+4932 -5300
View File
File diff suppressed because it is too large Load Diff
-5334
View File
File diff suppressed because it is too large Load Diff
-22448
View File
File diff suppressed because it is too large Load Diff