Skip to content

Commit

Permalink
add singleton change to api-kit and protocol-kit
Browse files Browse the repository at this point in the history
update api-kit initialization
update createTransaction use
  • Loading branch information
dasanra committed Nov 23, 2023
1 parent 0616a40 commit 53646d2
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 88 deletions.
16 changes: 11 additions & 5 deletions safe-core-sdk/api-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@ 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 those chains where Safe provides a transaction service is enough to specify the chainId. You can specify your own service using the optional `txServiceUrl` parameter.

Check failure on line 50 in safe-core-sdk/api-kit/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] safe-core-sdk/api-kit/README.md#L50

[Vale.Terms] Use 'Transaction Service' instead of 'transaction service'.
Raw output
{"message": "[Vale.Terms] Use 'Transaction Service' instead of 'transaction service'.", "location": {"path": "safe-core-sdk/api-kit/README.md", "range": {"start": {"line": 50, "column": 85}}}, "severity": "ERROR"}

Check failure on line 50 in safe-core-sdk/api-kit/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] safe-core-sdk/api-kit/README.md#L50

[Vale.Spelling] Did you really mean 'chainId'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'chainId'?", "location": {"path": "safe-core-sdk/api-kit/README.md", "range": {"start": {"line": 50, "column": 130}}}, "severity": "ERROR"}

```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'
})
```

Expand All @@ -72,14 +78,14 @@ const safe = await Safe.create({
})

// 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 safe.createTransaction({ transactions: [safeTransactionData] })

const senderAddress = await signer.getAddress()
const safeTxHash = await safe.getTransactionHash(safeTransaction)
Expand Down
6 changes: 3 additions & 3 deletions safe-core-sdk/api-kit/reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ Returns the information and configuration of the service.
const serviceInfo: SafeServiceInfoResponse = await safeService.getServiceInfo()
```

### `getServiceMasterCopiesInfo`
### `getServiceSingletonsInfo`

Returns the list of Safe master copies.
Returns the list of Safe singletons.

```typescript
const masterCopies: MasterCopyResponse = await safeService.getServiceMasterCopiesInfo()
const singletons: SafeSingletonResponse = await safeService.getServiceSingletonsInfo()
```

### `decodeData`
Expand Down
2 changes: 1 addition & 1 deletion safe-core-sdk/auth-kit/guides/web3auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const safeTransactionData: MetaTransactionData = {
value: ethers.parseUnits('0.0001', 'ether').toString()
}

const safeTransaction = await safeSDK.createTransaction({ safeTransactionData })
const safeTransaction = await safeSDK.createTransaction({ transactions: [safeTransactionData] })
```

## Sign messages using the `Web3AuthModalPack`
Expand Down
2 changes: 1 addition & 1 deletion safe-core-sdk/auth-kit/reference/Web3AuthModalPack.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ await web3AuthModalPack.init(web3AuthModalOptions, adapters, modalConfig)
// Sign in
const { eoa, safes } = await web3AuthModalPack.signIn()
const userInfo = await web3AuthModalPack.getUserInfo()
const BrowserProvider = web3AuthModalPack.getProvider()
const web3Provider = web3AuthModalPack.getProvider()

// Subscribe to events
const handler = (event) => {}
Expand Down
20 changes: 14 additions & 6 deletions safe-core-sdk/protocol-kit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,23 @@ const ethAdapterOwner1 = new EthersAdapter({

### Initialize the API Kit

The [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) consumes the [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service). To start using this library, create a new instance of the `SafeApiKit` class, imported from `@safe-global/api-kit`, and pass the Safe Transaction Service URL for your desired network to the constructor of the `SafeApiKit`.
The [API Kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) consumes the [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service). To start using this library, create a new instance of the `SafeApiKit` class, imported from `@safe-global/api-kit. In those chains where Safe provides a transaction service is enough to specify the chainId. You can specify your own service using the optional `txServiceUrl` parameter.

You will be using Goerli for this tutorial, however, you can also get [service URLs for different networks](../../safe-core-api/available-services.md).

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

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


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

### Initialize the Protocol Kit
Expand Down Expand Up @@ -187,19 +195,19 @@ The high-level overview of a multi-sig transaction is PCE: Propose. Confirm. Exe
For more details on what to include in a transaction see [Create a Transaction in the Safe Core SDK Guide](https://github.com/safe-global/safe-core-sdk/blob/main/guides/integrating-the-safe-core-sdk.md#4-create-a-transaction).

```tsx
import { SafeTransactionDataPartial } from '@safe-global/safe-core-sdk-types'
import { MetaTransactionData } from '@safe-global/safe-core-sdk-types'

// Any address can be used. In this example you will use vitalik.eth
const destination = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
const amount = ethers.parseUnits('0.005', 'ether').toString()

const safeTransactionData: SafeTransactionDataPartial = {
const safeTransactionData: MetaTransactionData = {
to: destination,
data: '0x',
value: amount
}
// Create a Safe transaction with the provided parameters
const safeTransaction = await safeSdkOwner1.createTransaction({ safeTransactionData })
const safeTransaction = await safeSdkOwner1.createTransaction({ transactions: [safeTransactionData] })
```

### Propose the transaction
Expand Down
Loading

0 comments on commit 53646d2

Please sign in to comment.