Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sdk new release updates #690

Merged
merged 32 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dff3f98
Update api-kit reference
yagopv Feb 10, 2025
f771e33
Reflect protocol-kit breaking changes
yagopv Feb 10, 2025
33d1906
FeeEstimator API change
yagopv Feb 10, 2025
b3a7859
Updates for custom nonces
yagopv Feb 10, 2025
0a7602d
Update Safe4337 guide
yagopv Feb 11, 2025
deea304
Add default module version
yagopv Feb 13, 2025
0f31f34
Update migration guide
yagopv Feb 14, 2025
3f198ac
Some updates
yagopv Feb 14, 2025
c64d5e4
Remove banner
yagopv Feb 14, 2025
fac62a2
Updates api-kit
yagopv Feb 14, 2025
fe70d1c
Update pages/reference-sdk-api-kit/getincomingtransactions.mdx
yagopv Feb 17, 2025
16a8740
Update pages/reference-sdk-api-kit/getpendingsafeoperations.mdx
yagopv Feb 17, 2025
ebce722
Rename file
yagopv Feb 17, 2025
4351536
Update pages/reference-sdk-api-kit/getsafeoperationsbyaddress.mdx
yagopv Feb 17, 2025
892b37f
Align type names
yagopv Feb 17, 2025
9ad9d9d
Publish api-kit migration guide
yagopv Feb 17, 2025
abe2779
Update pages/sdk/protocol-kit/guides/migrate-to-v6.md
yagopv Feb 20, 2025
a7e2e63
Set default safeModulesVersion to 0.2.0
yagopv Feb 20, 2025
37277d1
Merge branch 'sdk-new-release-updates' of https://github.com/safe-glo…
yagopv Feb 20, 2025
b0df31d
Add information about safe-operation endpoints in the api-kit
yagopv Feb 20, 2025
21bafc0
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
44f38bf
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
9dd7960
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
682eea4
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
3fcb5ef
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
76b9b60
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
d8fc924
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
fb86666
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
53855c5
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
a3a6fc2
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
58b38ac
Update pages/core-api/transaction-service-guides/messages.mdx
louis-md Feb 27, 2025
a9c29ba
Merge branch 'main' into sdk-new-release-updates
louis-md Feb 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading