Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/safe-global/safe-docs into …
Browse files Browse the repository at this point in the history
…glossary
  • Loading branch information
louis-md committed Dec 6, 2023
2 parents 1c9fe73 + 6afed64 commit b999977
Show file tree
Hide file tree
Showing 29 changed files with 1,055 additions and 646 deletions.
30 changes: 18 additions & 12 deletions .github/scripts/generateSupportedNetworks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// This script generates the supported networks page from the safe-deployments repo.
// It clones the repo, reads the JSON files, and generates the markdown files as well as a _meta.json file for nextra.

const shell = require('shelljs')
const fs = require('fs')
const path = require('path')

// Explore a given directory recursively and return all the file paths
const walkPath = dir => {
let results = []
const list = fs.readdirSync(dir)
Expand All @@ -18,16 +22,14 @@ const walkPath = dir => {
return results
}

const deduplicate = () => [
(acc, curr) => {
if (acc.includes(curr)) {
return acc
}
// Reduce function to deduplicate an array
const deduplicate = (acc, curr) => {
if (acc.includes(curr)) {
return acc
}

return [...acc, curr]
},
[]
]
return [...acc, curr]
}

const supportedNetworksPath = './safe-smart-account/supported-networks'

Expand Down Expand Up @@ -63,7 +65,7 @@ const generateSupportedNetworks = async () => {
const versions = contracts
.flat()
.map(c => c.version)
.reduce(...deduplicate())
.reduce(deduplicate, [])
.reverse()

shell.mkdir(supportedNetworksPath)
Expand Down Expand Up @@ -102,7 +104,8 @@ ${_contracts
.map(
c =>
`- \`${c.name}.sol\`: ${
c.blockExplorerUrl == null || deprecatedBlockExplorers.includes(c.blockExplorerUrl)
c.blockExplorerUrl == null ||
deprecatedBlockExplorers.includes(c.blockExplorerUrl)
? c.address
: `[${c.address}](${c.blockExplorerUrl}/address/${c.address})`
}`
Expand All @@ -128,6 +131,7 @@ const deprecatedBlockExplorers = [
'https://stardust-explorer.metis.io',
'https://blockexplorer.rinkeby.boba.network',
'https://blockexplorer.bobabeam.boba.network',
'https://blockexplorer.avax.boba.network',
'https://rabbit.analogscan.com',
'https://explorer.eurus.network',
'https://testnetexplorer.eurus.network',
Expand All @@ -137,4 +141,6 @@ const deprecatedBlockExplorers = [
'https://evm.explorer.canto.io',
'https://explorer.autobahn.network',
'https://explorer.cascadia.foundation',
]
'https://testnet.torusscan.com',
'https://testnet.toruscan.com'
]
8 changes: 7 additions & 1 deletion .github/styles/Vocab/default/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Cronos
Crossbell
DAO
Darwinia
Devnet
EIP
ERC
ETH
Expand Down Expand Up @@ -72,7 +73,7 @@ Kovan
LUKSO
Lightlink
Linea
MainNet
middleware
Mainnet
Mandala
Mantle
Expand All @@ -87,6 +88,7 @@ Moonbeam
Moonriver
Mordor
Nova
OAuth
OP
Offchain
Onramp
Expand Down Expand Up @@ -142,6 +144,7 @@ Ultron
Velas
Venidium
WEMIX3.0
WebSocket
WSGI
XDC
ZetaChain
Expand All @@ -160,8 +163,11 @@ endembed
endhint
multisig
npm
onboarding
offchain
onchain
pluggable
reauthenticate
sdk
undefined
v1
Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/generate-supported-networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,13 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: '20.x'
cache: 'yarn'
cache-dependency-path: ./yarn.lock
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v3
id: yarn-cache
- uses: pnpm/action-setup@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
version: 8
- name: Install dependencies
run: pnpm install
- name: Generate supported networks
run: node ./.github/scripts/generateSupportedNetworks.js
run: pnpm generate-supported-networks
- uses: actions/checkout@v4
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ This section in the documentation has relevant information and tutorials on the

## Safe{Core} API

The [Safe{Core} API](safe-core-api/available-services.md) refers to all the Safe infrastructure needed to power interfaces with all Safe account related information. This includes the Safe Transaction Service, Safe Events Service, etc.
The [Safe{Core} API](safe-core-api/supported-networks.md) refers to all the Safe infrastructure needed to power interfaces with all Safe account related information. This includes the Safe Transaction Service, Safe Events Service, etc.

This section in the documentation has information related to the services architecture.
17 changes: 12 additions & 5 deletions SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@

* [Auth Kit](safe-core-sdk/auth-kit/README.md)
* [Guides](safe-core-sdk/auth-kit/guides/README.md)
* [Web3Auth](safe-core-sdk/auth-kit/guides/web3auth.md)
* [SafeAuth](safe-core-sdk/auth-kit/guides/safe-auth.md)
* [Reference](safe-core-sdk/auth-kit/reference/README.md)
* [AuthKitBasePack](safe-core-sdk/auth-kit/reference/AuthKitBasePack.md)
* [Web3AuthModalPack](safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md)
* [SafeAuthPack](safe-core-sdk/auth-kit/reference/SafeAuthPack.md)

* [Protocol Kit](safe-core-sdk/protocol-kit/README.md)
* [Reference](safe-core-sdk/protocol-kit/reference/README.md)
* [Migrating to v2](safe-core-sdk/protocol-kit/reference/migrating/v2.md)
* [Migrating to v1](safe-core-sdk/protocol-kit/reference/migrating/v1.md)

* [Onramp Kit](safe-core-sdk/onramp-kit/README.md)
* [Guides](safe-core-sdk/onramp-kit/guides/README.md)
Expand All @@ -47,23 +49,28 @@
* [Relay Kit](safe-core-sdk/relay-kit/README.md)
* [Guides](safe-core-sdk/relay-kit/guides/README.md)
* [Gelato Relay](safe-core-sdk/relay-kit/guides/gelato.md)
* [Reference](safe-core-sdk/relay-kit/reference/README.md)
* [Migrating to v2](safe-core-sdk/relay-kit/reference/migrating/v2.md)

* [API Kit](safe-core-sdk/api-kit/README.md)
* [Reference](safe-core-sdk/api-kit/reference/README.md)
* [Migrating to v2](safe-core-sdk/api-kit/reference/migrating/v2.md)
* [Migrating to v1](safe-core-sdk/api-kit/reference/migrating/v1.md)


## Safe{Core} Protocol

* [Overview](safe-core-protocol/README.md)

## Safe{Core} API

* [Available Services](safe-core-api/available-services.md)

* [Service Architecture](safe-core-api/service-architecture.md)
* [Safe Transaction Service](safe-core-api/safe-transaction-service.md)

* [RPC Requirements](safe-core-api/rpc-requirements.md)

* [Supported Networks](safe-core-api/supported-networks.md)

## Safe Apps SDK

* [Overview](safe-apps/README.md)
Expand All @@ -76,5 +83,5 @@

* [Glossary](miscellaneous/glossary.md)
* [Bug Bounty](miscellaneous/bug-bounty-program.md)
* [Past paid bounties](miscellaneous/past-paid-bounties.md)
* [Past paid bounties](miscellaneous/past-paid-bounties.md)
* [Contact us](miscellaneous/contact-us.md)
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"scripts": {
"generate-supported-networks": "node .github/scripts/generateSupportedNetworks.js"
},
"dependencies": {
"node-fetch": "^3.3.2",
"shelljs": "^0.8.5"
Expand Down
2 changes: 2 additions & 0 deletions safe-apps/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ module.exports = {
}
```

We also offer a [middleware](https://github.com/safe-global/safe-apps-sdk/blob/4dad4fdf700ed299d3a81cc08cd4928b137787e9/packages/cra-template-safe-app/template/src/setupProxy.js#L1-L15) in our React template for using frameworks like Express, Next.js, etc.

**SSL**

To enable SSL with `react-scripts`, it is necessary to set the `HTTPS` environment variable to `true`. This can be done in the `package.json` file by adjusting the `scripts` section to:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
description: This pages provides an overview of the available services
description: This page provides an overview of the available services
---

# Available Services
# Supported Networks

## Safe Transaction Service

Expand All @@ -21,4 +21,5 @@ description: This pages provides an overview of the available services
| Optimism | [https://safe-transaction-optimism.safe.global](https://safe-transaction-optimism.safe.global/) |
| Polygon | [https://safe-transaction-polygon.safe.global](https://safe-transaction-polygon.safe.global/) |
| Polygon zkEVM | [https://safe-transaction-zkevm.safe.global](https://safe-transaction-zkevm.safe.global/) |
| Sepolia | [https://safe-transaction-sepolia.safe.global](https://safe-transaction-sepolia.safe.global/) |
| zkSync Era Mainnet | [https://safe-transaction-zksync.safe.global](https://safe-transaction-zksync.safe.global/) |
38 changes: 22 additions & 16 deletions safe-core-sdk/api-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ yarn add @safe-global/api-kit

## Instantiate an EthAdapter

First of all, we need to create an `EthAdapter`, which contains all the required utilities for the SDKs to interact with the blockchain. It acts as a wrapper for [web3.js](https://web3js.readthedocs.io/) or [ethers.js](https://docs.ethers.io/v5/) Ethereum libraries.
First of all, we need to create an `EthAdapter`, which contains all the required utilities for the SDKs to interact with the blockchain. It acts as a wrapper for [web3.js](https://web3js.readthedocs.io/) or [ethers.js](https://docs.ethers.org/v6/) Ethereum libraries.

Depending on the library used by the Dapp, there are two options:

Expand All @@ -36,7 +36,7 @@ Once the instance of `EthersAdapter` or `Web3Adapter` is created, it can be used
```typescript
import { EthersAdapter } from '@safe-global/protocol-kit'

const provider = new ethers.providers.JsonRpcProvider(config.RPC_URL)
const provider = new ethers.JsonRpcProvider(config.RPC_URL)
const signer = new ethers.Wallet(config.SIGNER_ADDRESS_PRIVATE_KEY, provider)

const ethAdapter = new EthersAdapter({
Expand All @@ -47,47 +47,53 @@ const ethAdapter = new EthersAdapter({

## Initialize the API Kit

We need to create an instance of the API Kit.
We need to create an instance of the API Kit. In chains where Safe provides a Transaction Service, it's enough to specify the `chainId`. You can set your own service using the optional `txServiceUrl` parameter.

```typescript
import SafeApiKit from '@safe-global/api-kit'

const safeApiKit = new SafeApiKit({
txServiceUrl: 'https://safe-transaction-mainnet.safe.global',
ethAdapter
chainId: 1n
})


// or using a custom service
const safeApiKit = new SafeApiKit({
chainId: 1n, // set the correct chainId
txServiceUrl: 'https://url-to-your-custom-service'
})
```

## Propose a transaction to the service

Before a transaction can be executed, any of the Safe signers needs to initiate the process by creating a proposal of a transaction. We send this transaction to the service to make it accessible by the other owners so they can give their approbal and sign the transaction as well.
Before a transaction can be executed, any of the Safe signers needs to initiate the process by creating a proposal of a transaction. We send this transaction to the service to make it accessible by the other owners so they can give their approval and sign the transaction as well.

```typescript
import Safe from '@safe-global/protocol-kit'

// Create Safe instance
const safe = await Safe.create({
const protocolKit = await Safe.create({
ethAdapter,
safeAddress: config.SAFE_ADDRESS
})

// Create transaction
const safeTransactionData: SafeTransactionDataPartial = {
const safeTransactionData: MetaTransactionData = {
to: '0x',
value: '1', // 1 wei
data: '0x',
operation: OperationType.Call
}

const safeTransaction = await safe.createTransaction({ safeTransactionData })
const safeTransaction = await protocolKit.createTransaction({ transactions: [safeTransactionData] })

const senderAddress = await signer.getAddress()
const safeTxHash = await safe.getTransactionHash(safeTransaction)
const signature = await safe.signTransactionHash(safeTxHash)
const safeTxHash = await protocolKit.getTransactionHash(safeTransaction)
const signature = await protocolKit.signTransactionHash(safeTxHash)

// Propose transaction to the service
await safeApiKit.proposeTransaction({
safeAddress: await safe.getAddress(),
safeAddress: await protocolKit.getAddress(),
safeTransactionData: safeTransaction.data,
safeTxHash,
senderAddress,
Expand All @@ -110,14 +116,14 @@ const transaction = await service.getTransaction("<SAFE_TX_HASH>")

## Confirm the transaction

In this step we need to sing the transaction with the Protocol Kit and submit the signature the the Safe Transaction Service using the `confirmTransaction` method.
In this step we need to sign the transaction with the Protocol Kit and submit the signature to the Safe Transaction Service using the `confirmTransaction` method.

```typescript
const safeTxHash = transaction.transactionHash
const signature = await safe.signTransactionHash(safeTxHash)
const signature = await protocolKit.signTransactionHash(safeTxHash)

// Confirm the Safe transaction
const signatureResponse = await service.confirmTransaction(safeTxHash, signature.data)
const signatureResponse = await safeApiKit.confirmTransaction(safeTxHash, signature.data)
```

The Safe transaction is now ready to be executed. This can be done using the Safe{Wallet} web interface, the Protocol Kit or any other tool that is available.
The Safe transaction is now ready to be executed. This can be done using the Safe{Wallet} web interface, the Protocol Kit or any other tool that's available.
Loading

0 comments on commit b999977

Please sign in to comment.