Skip to content

Commit

Permalink
Sdk new release updates (#690)
Browse files Browse the repository at this point in the history
* Update api-kit reference

* Reflect protocol-kit breaking changes

* FeeEstimator API change

* Updates for custom nonces

* Update Safe4337 guide

* Add default module version

* Update migration guide

* Some updates

* Remove banner

* Updates api-kit

* Update pages/reference-sdk-api-kit/getincomingtransactions.mdx

Co-authored-by: Daniel <[email protected]>

* Update pages/reference-sdk-api-kit/getpendingsafeoperations.mdx

Co-authored-by: Daniel <[email protected]>

* Rename file

* Update pages/reference-sdk-api-kit/getsafeoperationsbyaddress.mdx

Co-authored-by: Daniel <[email protected]>

* Align type names

* Publish api-kit migration guide

* Update pages/sdk/protocol-kit/guides/migrate-to-v6.md

Co-authored-by: Daniel <[email protected]>

* Set default safeModulesVersion to 0.2.0

* Add information about safe-operation endpoints in the api-kit

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

* Update pages/core-api/transaction-service-guides/messages.mdx

---------

Co-authored-by: Daniel <[email protected]>
Co-authored-by: louis-md <[email protected]>
  • Loading branch information
3 people authored Feb 27, 2025
1 parent 83e8715 commit c1c4c17
Show file tree
Hide file tree
Showing 25 changed files with 564 additions and 139 deletions.
110 changes: 59 additions & 51 deletions pages/core-api/transaction-service-guides/messages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,53 @@ The different steps are implemented using [Curl](https://github.com/curl/curl) r
<Steps>
### Install dependencies

{/* <!-- vale off --> */}

<Tabs items={['TypeScript', 'Python']}>
<Tabs.Tab>
```bash
yarn add @safe-global/api-kit @safe-global/protocol-kit @safe-global/types-kit
```
</Tabs.Tab>
<Tabs.Tab>
{/* <!-- vale off --> */}

{' '}
<Tabs items={['TypeScript', 'Python']}>
<Tabs.Tab>
```bash
yarn add @safe-global/api-kit @safe-global/protocol-kit @safe-global/types-kit
```
</Tabs.Tab>
<Tabs.Tab>
```bash
pip install safe-eth-py web3 hexbytes
```
</Tabs.Tab>
</Tabs>
</Tabs.Tab>
</Tabs>

{/* <!-- vale on --> */}
{/* <!-- vale on --> */}

### Imports
### Imports

{/* <!-- vale off --> */}
{/* <!-- vale off --> */}

<Tabs items={['TypeScript', 'Python']}>
<Tabs.Tab>
```typescript
import SafeApiKit, { AddMessageProps } from '@safe-global/api-kit'
import Safe, { hashSafeMessage } from '@safe-global/protocol-kit'
```
</Tabs.Tab>
<Tabs.Tab>
```python
from datetime import datetime
from eth_account import Account
from eth_account.messages import defunct_hash_message
from safe_eth.eth import EthereumClient, EthereumNetwork
from safe_eth.safe import Safe
from safe_eth.safe.api.transaction_service_api import TransactionServiceApi
```
</Tabs.Tab>
</Tabs>
{' '}
<Tabs items={['TypeScript', 'Python']}>
<Tabs.Tab>
```typescript
import SafeApiKit, {AddMessageOptions} from '@safe-global/api-kit'
import Safe, {hashSafeMessage} from '@safe-global/protocol-kit'
```
</Tabs.Tab>
<Tabs.Tab>
```python
from datetime import datetime
from eth_account import Account
from eth_account.messages import defunct_hash_message
from safe_eth.eth import EthereumClient, EthereumNetwork
from safe_eth.safe import Safe
from safe_eth.safe.api.transaction_service_api import TransactionServiceApi
```
</Tabs.Tab>
</Tabs>

{/* <!-- vale on --> */}
{/* <!-- vale on --> */}

### Create a Safe message
### Create a Safe message

{/* <!-- vale off --> */}
{/* <!-- vale off --> */}

<Tabs items={['TypeScript', 'Python', 'Curl']}>
<Tabs.Tab>
Expand Down Expand Up @@ -102,13 +104,14 @@ The different steps are implemented using [Curl](https://github.com/curl/curl) r
}'
```
</Tabs.Tab>

</Tabs>

{/* <!-- vale on --> */}
{/* <!-- vale on --> */}

### Sign the message
### Sign the message

{/* <!-- vale off --> */}
{/* <!-- vale off --> */}

<Tabs items={['TypeScript', 'Python', 'Curl']}>
<Tabs.Tab>
Expand All @@ -130,13 +133,14 @@ The different steps are implemented using [Curl](https://github.com/curl/curl) r
<Tabs.Tab>
We skip this step because the message we created in the Transaction Service using Curl already has the signature of the message creator. Check the [Create a Safe message](#create-a-safe-message) step.
</Tabs.Tab>

</Tabs>

{/* <!-- vale on --> */}
{/* <!-- vale on --> */}

### Send the message to the service
### Send the message to the service

{/* <!-- vale off --> */}
{/* <!-- vale off --> */}

<Tabs items={['TypeScript', 'Python', 'Curl']}>
<Tabs.Tab>
Expand All @@ -146,7 +150,7 @@ The different steps are implemented using [Curl](https://github.com/curl/curl) r
chainId: 11155111n
})

const messageProps: AddMessageProps = {
const messageProps: AddMessageOptions = {
message: rawMessage,
signature: signedMessageOwnerA.encodedSignatures()
}
Expand All @@ -172,15 +176,16 @@ The different steps are implemented using [Curl](https://github.com/curl/curl) r
<Tabs.Tab>
We skip this step because the message we created using Curl is already in the Transaction Service. Check the [Create a Safe message](#create-a-safe-message) step.
</Tabs.Tab>

</Tabs>

{/* <!-- vale on --> */}
{/* <!-- vale on --> */}

### Collect the missing signatures
### Collect the missing signatures

#### Get the pending message
#### Get the pending message

{/* <!-- vale off --> */}
{/* <!-- vale off --> */}

<Tabs items={['TypeScript', 'Python', 'Curl']}>
<Tabs.Tab>
Expand Down Expand Up @@ -214,13 +219,14 @@ The different steps are implemented using [Curl](https://github.com/curl/curl) r
-H 'accept: application/json' \
```
</Tabs.Tab>

</Tabs>

{/* <!-- vale on --> */}
{/* <!-- vale on --> */}

#### Add missing signatures
#### Add missing signatures

{/* <!-- vale off --> */}
{/* <!-- vale off --> */}

<Tabs items={['TypeScript', 'Python', 'Curl']}>
<Tabs.Tab>
Expand All @@ -230,7 +236,7 @@ The different steps are implemented using [Curl](https://github.com/curl/curl) r

// Get Owner B address
const ownerBAddress = '0x...'

// Send the message to the Transaction Service with the signature from Owner B
await apiKit.addMessageSignature(
safeMessageHash,
Expand Down Expand Up @@ -261,7 +267,9 @@ The different steps are implemented using [Curl](https://github.com/curl/curl) r
}'
```
</Tabs.Tab>

</Tabs>

{/* <!-- vale on --> */}
{/* <!-- vale on --> */}

</Steps>
3 changes: 2 additions & 1 deletion pages/reference-sdk-api-kit/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"constructor": "constructor",
"getserviceinfo": "getServiceInfo",
"getservicesingletonsinfo": "getServiceSingletonsInfo",
"decodeddata": "decodedData",
"decodedata": "decodeData",
"getsafesbyowner": "getSafesByOwner",
"getsafesbymodule": "getSafesByModule",
"gettransaction": "getTransaction",
Expand All @@ -37,6 +37,7 @@
"addmessage": "addMessage",
"addmessagesignature": "addMessageSignature",
"getsafeoperationsbyaddress": "getSafeOperationsByAddress",
"getpendingsafeoperations": "getPendingSafeOperations",
"getsafeoperation": "getSafeOperation",
"addsafeoperation": "addSafeOperation",
"getsafeoperationconfirmations": "getSafeOperationConfirmations",
Expand Down
4 changes: 2 additions & 2 deletions pages/reference-sdk-api-kit/addmessage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Creates a new message with an initial signature.
<Tabs items={['example.ts', 'setup.ts']}>
<Tabs.Tab>
```typescript
import { AddMessageProps } from '@safe-global/api-kit'
import { AddMessageOptions } from '@safe-global/api-kit'
import { apiKit } from './setup.ts'

const safeAddress = '0x...'

const config: AddMessageProps = {
const config: AddMessageOptions = {
message: '0x...',
signature: '0x...',
safeAppId: 1 // Optional
Expand Down
10 changes: 9 additions & 1 deletion pages/reference-sdk-api-kit/addsafeoperation.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { Tabs } from 'nextra/components'
import { Tabs, Callout } from 'nextra/components'

# `addSafeOperation`

Adds a new ERC-4337 Safe operation for a given Safe account.

<Callout type="info" emoji="ℹ️">
The SafeOperations methods are currently compatible with Entrypoint v0.6, which corresponds to `safeModuleVersion` v0.2.0. If you need to use v0.7, you should use the `relay-kit` `Safe4337Pack` class with `safeModuleVersion` v0.3.0, and collect the signatures yourself.

Examples of how to use the `Safe4337Pack` are provided in the following links:
- [Playgrounds](https://github.com/safe-global/safe-core-sdk/tree/main/playground/relay-kit)
- [Guide](https://docs.safe.global/sdk/relay-kit/guides/4337-safe-sdk)
</Callout>

## Usage

A Safe operation can be created by using the [createTransaction](../sdk/relay-kit/reference/safe-4337-pack.mdx#createtransactionsafe4337createtransactionprops) method from the `Safe4337Pack`.
Expand Down
10 changes: 9 additions & 1 deletion pages/reference-sdk-api-kit/confirmsafeoperation.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { Tabs } from 'nextra/components'
import { Tabs, Callout } from 'nextra/components'

# `confirmSafeOperation`

Adds a confirmation for a Safe operation. Once enough confirmations are collected, the Safe operation needs to be executed via the `executeTransaction` method from the `Safe4337Pack`.

<Callout type="info" emoji="ℹ️">
The SafeOperations methods are currently compatible with Entrypoint v0.6, which corresponds to `safeModuleVersion` v0.2.0. If you need to use v0.7, you should use the `relay-kit` `Safe4337Pack` class with `safeModuleVersion` v0.3.0, and collect the signatures yourself.

Examples of how to use the `Safe4337Pack` are provided in the following links:
- [Playgrounds](https://github.com/safe-global/safe-core-sdk/tree/main/playground/relay-kit)
- [Guide](https://docs.safe.global/sdk/relay-kit/guides/4337-safe-sdk)
</Callout>

## Usage

{/* <!-- vale off --> */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@ Decodes the specified Safe transaction data.

## Returns

`Promise<any>`
`Promise<DataDecoded>`

The transaction data decoded.

```typescript
type DataDecoded = {
readonly method: string
readonly parameters: DecodedParameters[]
}
```
## Parameters
### `data`
Expand All @@ -45,8 +52,19 @@ The transaction data decoded.
The Safe transaction data to decode.
```typescript focus=2
```typescript
const decodedData = await apiKit.decodeData('0x...')
```

### `to` (Optional)

- **Type:** `string`

The address of the receiving contract. If provided, the decoded data will be more accurate, as in case of an ABI collision the Safe Transaction Service would know which ABI to use

```typescript
const decodedData = await apiKit.decodeData(
'0x...',
'0x...'
)
```
25 changes: 24 additions & 1 deletion pages/reference-sdk-api-kit/getincomingtransactions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ Returns the history of incoming transactions of a Safe account.
import { apiKit } from './setup.ts'

const safeAddress = '0x...'
const options = {
_from: '0x...',
limit: 10,
offset: 10
}

const incomingTxs = await apiKit.getIncomingTransactions(safeAddress)
const incomingTxs = await apiKit.getIncomingTransactions(safeAddress, options)
```
</Tabs.Tab>
<Tabs.Tab>
Expand Down Expand Up @@ -50,3 +55,21 @@ const incomingTxs = await apiKit.getIncomingTransactions(
'0x...'
)
```

### `options.from` (Optional)

- **Type:** `string`

The transaction sender address.

### `options.limit` (Optional)

- **Type:** `number`

The number of results to return per page.

### `options.offset` (Optional)

- **Type:** `number`

The initial index from which to return the results.
4 changes: 2 additions & 2 deletions pages/reference-sdk-api-kit/getmessages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ Returns the list of messages associated to a Safe account.
<Tabs items={['example.ts', 'setup.ts']}>
<Tabs.Tab>
```typescript
import { GetSafeMessageListProps } from '@safe-global/api-kit'
import { GetSafeMessageListOptions } from '@safe-global/api-kit'
import { apiKit } from './setup.ts'

const safeAddress = '0x...'

const config: GetSafeMessageListProps = {
const config: GetSafeMessageListOptions = {
ordering: 'created', // Optional
limit: '10', // Optional
offset: '50' // Optional
Expand Down
27 changes: 24 additions & 3 deletions pages/reference-sdk-api-kit/getmoduletransactions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ Returns the history of module transactions of a Safe account.
import { apiKit } from './setup.ts'

const safeAddress = '0x...'
const options = {
module: '0x...',
limit: 10,
offset: 10
}

const moduleTxs = await apiKit.getModuleTransactions(
safeAddress
)
const moduleTxs = await apiKit.getModuleTransactions(safeAddress, options)
```
</Tabs.Tab>
<Tabs.Tab>
Expand Down Expand Up @@ -52,3 +55,21 @@ const moduleTxs = await apiKit.getModuleTransactions(
'0x...'
)
```

### `options.module` (Optional)

- **Type:** `string`

The module to get the transactions from.

### `options.limit` (Optional)

- **Type:** `number`

The number of results to return per page.

### `options.offset` (Optional)

- **Type:** `number`

The initial index from which to return the results.
Loading

0 comments on commit c1c4c17

Please sign in to comment.