Skip to content

Commit

Permalink
Updates across the documentation for web3.py examples
Browse files Browse the repository at this point in the history
  • Loading branch information
fselmo committed May 23, 2024
1 parent a764337 commit 9eeca54
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/local/config/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const LanguagePresets = configureLanguages({
},
web3py: {
icon: '',
name: 'Web3.py',
name: 'web3.py',
language: 'python',
fallback: [],
},
Expand Down
14 changes: 13 additions & 1 deletion app/src/components/Libraries.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from 'next/link';
import { ReactNode } from 'react';
import { FaJava, FaReact, FaRust } from 'react-icons/fa';
import { SiDelphi, SiKotlin, SiNuget } from 'react-icons/si';
import { SiDelphi, SiKotlin, SiNuget, SiPython } from 'react-icons/si';
import { TbBrandGolang, TbBrandJavascript } from 'react-icons/tb';

type Language = {
Expand Down Expand Up @@ -80,6 +80,18 @@ export const ensLibraries: Language[] = [
},
],
},
{
name: 'Python',
logo: <SiPython />,
libraries: [
{
href: 'https://github.com/ethereum/web3.py',
name: 'web3.py',
description: 'A python interface for interacting with the Ethereum blockchain and ecosystem.',
logo: undefined,
},
],
},
{
name: 'NuGet',
logo: <SiNuget />,
Expand Down
1 change: 1 addition & 0 deletions docs/dao/proposals/3.7.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ This is a vote to approve [ENSIP-15: Normalization Standard.](https://docs.ens.d
1. Javascript — [adraffy/ens-normalize](https://github.com/adraffy/ens-normalize.js)
2. Javascript — [ensdomains/eth-ens-namehash](https://github.com/ensdomains/eth-ens-namehash)
3. Python — [namehash/ens-normalize-python](https://github.com/namehash/ens-normalize-python)
4. Python - [ethereum/web3.py](https://github.com/ethereum/web3.py)
* Web Frameworks using ENSIP-15:
1. Javascript — [ethers/ethers.io](https://github.com/ethers-io/ethers.js/)
2. Javascript — [web3/web3.js](https://github.com/web3/web3.js)
Expand Down
6 changes: 6 additions & 0 deletions docs/resolution/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ const ensResolver = await publicClient.getEnsResolver({
});
```

```py {{ variant: 'web3py', link: 'https://web3py.readthedocs.io/en/latest/ens_overview.html#working-with-resolvers' }}
from ens.auto import ns

resolver = ns.resolver('alice.eth')
```

</CodeGroup>

To verify which specifications are implemented by a resolver you can call the `supportsInterface(bytes4 interfaceID)` on the resolver with the interfaceID you would like to test for.
Expand Down
6 changes: 6 additions & 0 deletions docs/web/avatars.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ const ensAvatar = await publicClient.getEnsAvatar({
});
```

```py {{ variant: 'web3py', link: 'https://web3py.readthedocs.io/en/latest/ens_overview.html#read-text-metadata-for-an-ens-record' }}
from ens.auto import ns

avatar = ns.get_text('alice.eth', 'avatar')
```

```go {{ title: "Go", variant: "go" }}
package main

Expand Down
11 changes: 11 additions & 0 deletions docs/web/records.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ const ensText = await publicClient.getEnsText({
});
```

```python {{ title: "web3.py", variant: "web3.py", link: "https://web3py.readthedocs.io/en/latest/ens_overview.html#text-records" }}
from ens.auto import ns

# set text
ns.set_text('alice.eth', 'url', 'https://example.com')

# get text
url = ns.get_text('alice.eth', 'url')
assert url == 'https://example.com'
```

```tsx {{ title: "Ethers.rs", variant: "rust" }}
// TODO: Not Implemented
```
Expand Down
15 changes: 12 additions & 3 deletions docs/web/resolution.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ const ensAddress = await publicClient.getEnsAddress({
});
```

```py {{ title: 'web3.py (Python)', variant: 'web3py', link: 'https://web3py.readthedocs.io/en/latest/ens_overview.html#get-the-address-for-an-ens-name' }}
from ens.auto import ns

address = ns.address('alice.eth')
```

```rust {{ variant: 'ethers-rs' }}
let provider = Provider::<Http>::try_from("https://mainnet.infura.io/v3/...")?;

Expand Down Expand Up @@ -123,9 +129,6 @@ const records = client.getRecords({
});
```

```python {{ variant: 'web3py' }}
address = ns.address('alice.eth')
```

```csharp {{ variant: "nethereum" }}
var ensService = new Nethereum.ENS.ENSService(web3);
Expand Down Expand Up @@ -172,6 +175,12 @@ const resolver = await provider.getResolver("luc.eth");
const btcAddress = await resolver?.getAddress(0);
```
```py {{ title: 'web3.py (Python)', variant: 'web3py', link: 'https://web3py.readthedocs.io/en/latest/ens_overview.html#multichain-address-resolution' }}
from ens.auto import ns

eth_address = ns.address('alice.eth', coin_type=60)
```
</CodeGroup>
| Network | Coin Type |
Expand Down
14 changes: 14 additions & 0 deletions docs/web/reverse.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ const ensName = await publicClient.getEnsName({
});
```

```py {{ variant: 'web3py', link: 'https://web3py.readthedocs.io/en/latest/ens_overview.html#get-the-ens-name-for-an-address' }}
from ens.auto import ns

# 0x225f137127d9067788314bc7fcc1f36746a3c3B5 -> luc.eth
name = ns.name('0x225f137127d9067788314bc7fcc1f36746a3c3B5')
```


```go {{ variant: 'go', title: 'Go' }}
package main

Expand Down Expand Up @@ -136,6 +144,12 @@ const hash = await setPrimaryName(wallet, {
// 0x...
```

```py {{ variant: 'web3py', link: 'https://web3py.readthedocs.io/en/latest/ens_overview.html#link-an-address-to-a-name' }}
from ens.auto import ns

ns.setup_name('myname.eth', my_address)
```

</CodeGroup>

### Do's and Dont's
Expand Down

0 comments on commit 9eeca54

Please sign in to comment.