Skip to content

Commit

Permalink
Merge branch 'development' into bump-safe-deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanra committed Sep 25, 2024
2 parents 78993b3 + 27c7a45 commit 57d3c99
Show file tree
Hide file tree
Showing 441 changed files with 5,522 additions and 20,907 deletions.
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ Please describe concisely the bug you have found.
- Safe Core SDK versions:
<!-- Please leave empty or delete those that you don't use. -->
- api-kit:
- auth-kit:
- onramp-kit
- protocol-kit:
- relay-kit:
- safe-core-sdk-types:
- types-kit:
- sdk-starter-kit:
- Safe contract version:
- Environment:
- browser
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/protocol-kit-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
- name: Test ${{ matrix.provider }} - Safe ${{ matrix.contract-version }}
run: |
cd packages/protocol-kit
ls -la $(pwd)/node_modules/.bin
yarn test:hardhat:${{ matrix.provider }}:${{ matrix.contract-version }}
2 changes: 0 additions & 2 deletions .github/workflows/sdk-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,5 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: packages/api-kit/coverage/lcov.info
packages/auth-kit/coverage/lcov.info
packages/onramp-kit/coverage/lcov.info
packages/relay-kit/coverage/lcov.info
packages/sdk-starter-kit/coverage/lcov.info
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ If you want to develop using Safe Smart Accounts in a Javascript/Typescript app,
| [protocol-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/protocol-kit) | [![npm Version](https://badge.fury.io/js/%40safe-global%2Fprotocol-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fprotocol-kit) | TypeScript library that facilitates the interaction with [Safe Smart Accounts](https://github.com/safe-global/safe-smart-account). Can be used to create new Safe accounts, update the configuration of existing Safes, create and execute transactions, among other features. |
| [api-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/api-kit) | [![npm Version](https://badge.fury.io/js/%40safe-global%2Fapi-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fapi-kit) | [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service) typescript library. Allows to propose and share transactions with the other signers of a Safe, sending the signatures to the service to collect them, and getting information about a Safe, among other features. |
| [relay-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/relay-kit) | ​​​[![npm Version](https://badge.fury.io/js/%40safe-global%2Frelay-kit.svg)](https://badge.fury.io/js/%40safe-global%2Frelay-kit)| Typescript library that enables ERC-4337 with Safe and allows users to pay for the transaction fees from their Safe account balance using the blockchain native token or ERC-20 tokens, or to get their transactions sponsored. |
| [safe-core-sdk-types](https://github.com/safe-global/safe-core-sdk/tree/main/packages/safe-core-sdk-types) | [![npm Version](https://badge.fury.io/js/%40safe-global%2Fsafe-core-sdk-types.svg)](https://badge.fury.io/js/%40safe-global%2Fsafe-core-sdk-types) | Common types used in the [Safe Core SDK](https://github.com/safe-global/safe-core-sdk/tree/main/packages) packages. |
| [auth-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/auth-kit) | [![npm Version](https://badge.fury.io/js/%40safe-global%2Fauth-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fauth-kit) | Typescript library to create an Ethereum address and authenticating a blockchain account using an email address, social media account, or traditional crypto wallets like Metamask. |
| [onramp-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/onramp-kit) | [![npm Version](https://badge.fury.io/js/%40safe-global%2Fonramp-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fonramp-kit) | Typescript library that allows users to buy cryptocurrencies using a credit card and other payment options. |
| [types-kit](https://github.com/safe-global/safe-core-sdk/tree/main/packages/types-kit) | [![npm Version](https://badge.fury.io/js/%40safe-global%2Ftypes-kit.svg)](https://badge.fury.io/js/%40safe-global%2Ftypes-kit) | Common types used in the [Safe Core SDK](https://github.com/safe-global/safe-core-sdk/tree/main/packages) packages. |

## Guides

Expand Down
2 changes: 1 addition & 1 deletion guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Read about the basics of Safe and [how it compares to other solutions](https://h
The [Safe Core SDK](https://github.com/safe-global/safe-core-sdk) is a monorepo that contains software developer tools that allows interaction with [Safe Smart Accounts](https://github.com/safe-global/safe-smart-account) and the [Safe Transaction Service API](https://github.com/safe-global/safe-transaction-service).

In this guide we will use the following packages to deploy new Safes, create transactions, collect off-chain signatures and execute transactions:
* **safe-core-sdk-types**
* **types-kit**

Contains the types that are shared among the different packages inside the monorepo.

Expand Down
4 changes: 2 additions & 2 deletions guides/integrating-the-safe-core-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
To integrate the [Safe Core SDK](https://github.com/safe-global/safe-core-sdk) into your Dapp or script you will need to install these dependencies:

```
@safe-global/safe-core-sdk-types
@safe-global/types-kit
@safe-global/protocol-kit
@safe-global/api-kit
```
Expand Down Expand Up @@ -143,7 +143,7 @@ When the array contains only one transaction, it is not wrapped in the MultiSend

```js
import { SafeTransactionOptionalProps } from '@safe-global/protocol-kit'
import { MetaTransactionData } from '@safe-global/safe-core-sdk-types'
import { MetaTransactionData } from '@safe-global/types-kit'

const transactions: MetaTransactionData[] = [
{
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
"author": "Safe (https://safe.global)",
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/jest": "^29.5.13",
"@types/node": "^20.14.5",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.11",
"eslint-plugin-prettier": "^5.2.1",
"husky": "^9.1.6",
"jest": "^29.7.0",
"lerna": "^8.1.3",
"lint-staged": "^15.2.7",
"prettier": "^3.3.2",
"lerna": "^8.1.8",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.5",
"ts-node": "^10.9.2",
Expand Down
2 changes: 0 additions & 2 deletions packages/api-kit/.env.example

This file was deleted.

52 changes: 0 additions & 52 deletions packages/api-kit/hardhat.config.ts

This file was deleted.

37 changes: 18 additions & 19 deletions packages/api-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"API"
],
"scripts": {
"test:web3": "export TESTS_PATH=tests/endpoint && export ETH_LIB=web3 && nyc hardhat test",
"test:ethers": "export TESTS_PATH=tests/endpoint && export ETH_LIB=ethers && nyc --reporter=lcov hardhat test",
"test:viem": "export TESTS_PATH=tests/endpoint && export ETH_LIB=viem && nyc hardhat test",
"test": "yarn test:ethers",
"test:ci:web3": "export TESTS_PATH=tests/e2e && export ETH_LIB=web3 && nyc hardhat test",
"test:ci:ethers": "export TESTS_PATH=tests/e2e && export ETH_LIB=ethers && nyc --reporter=lcov hardhat test",
"test:ci:viem": "export TESTS_PATH=tests/e2e && export ETH_LIB=viem && nyc --reporter=lcov hardhat test",
"test:ci": "yarn test:ci:ethers",
"test:web3": "export HARDHAT_NETWORK=sepolia && export ETH_LIB=web3 && nyc --reporter=lcov testing-kit test 'tests/endpoint/*.test.*'",
"test:ethers": "export HARDHAT_NETWORK=sepolia && export ETH_LIB=ethers && nyc --reporter=lcov testing-kit test 'tests/endpoint/*.test.*'",
"test:viem": "export HARDHAT_NETWORK=sepolia && export ETH_LIB=viem && nyc --reporter=lcov testing-kit test 'tests/endpoint/*.test.*'",
"test": "yarn test:viem",
"test:ci:web3": "export HARDHAT_NETWORK=sepolia && export ETH_LIB=web3 && nyc --reporter=lcov testing-kit test 'tests/e2e/*.test.*'",
"test:ci:ethers": "export HARDHAT_NETWORK=sepolia && export ETH_LIB=ethers && nyc --reporter=lcov testing-kit test 'tests/e2e/*.test.*'",
"test:ci:viem": "export HARDHAT_NETWORK=sepolia && export ETH_LIB=viem && nyc --reporter=lcov testing-kit test 'tests/e2e/*.test.*'",
"test:ci": "yarn test:ci:viem",
"format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"",
"format": "prettier --write \"*/**/*.{js,json,md,ts}\"",
"unbuild": "rimraf dist .nyc_output cache",
Expand All @@ -39,29 +39,28 @@
],
"homepage": "https://github.com/safe-global/safe-core-sdk#readme",
"devDependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.6",
"@types/chai": "^4.3.16",
"@safe-global/relay-kit": "^3.1.0",
"@safe-global/testing-kit": "^0.0.1-alpha.1",
"@types/chai": "^4.3.19",
"@types/chai-as-promised": "^7.1.8",
"@types/mocha": "^10.0.6",
"@types/mocha": "^10.0.8",
"@types/node-fetch": "^2.6.11",
"@types/sinon-chai": "^3.2.11",
"@types/yargs": "^17.0.32",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"hardhat": "2.20.1",
"ethers": "^6.13.2",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"semver": "^7.6.1",
"sinon": "^14.0.2",
"sinon-chai": "^3.7.0",
"tsconfig-paths": "^4.2.0",
"viem": "^2.15.1",
"web3": "^4.7.0",
"yargs": "^17.7.2"
"web3": "^4.12.1"
},
"dependencies": {
"@safe-global/protocol-kit": "^4.1.1",
"@safe-global/safe-core-sdk-types": "^5.1.0",
"ethers": "^6.13.1",
"node-fetch": "^2.7.0"
"@safe-global/types-kit": "^1.0.0",
"node-fetch": "^2.7.0",
"viem": "^2.21.8"
}
}
2 changes: 1 addition & 1 deletion packages/api-kit/src/SafeApiKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
SafeOperation,
SafeOperationConfirmationListResponse,
SafeOperationResponse
} from '@safe-global/safe-core-sdk-types'
} from '@safe-global/types-kit'
import { TRANSACTION_SERVICE_URLS } from './utils/config'
import { isEmptyData } from './utils'
import { getAddSafeOperationProps } from './utils/safeOperation'
Expand Down
6 changes: 6 additions & 0 deletions packages/api-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ import SafeApiKit, { SafeApiKitConfig } from './SafeApiKit'
export * from './types/safeTransactionServiceTypes'
export { SafeApiKitConfig }
export default SafeApiKit

declare module 'abitype' {
export interface Register {
AddressType: string
}
}
13 changes: 7 additions & 6 deletions packages/api-kit/src/types/safeTransactionServiceTypes.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Signer, TypedDataDomain, TypedDataField } from 'ethers'
import { Account, Chain, Transport, TypedDataDomain, TypedDataParameter, WalletClient } from 'viem'
import {
SafeMultisigTransactionResponse,
SafeTransactionData,
UserOperation,
SafeOperationResponse,
ListResponse
} from '@safe-global/safe-core-sdk-types'
} from '@safe-global/types-kit'

export type ListOptions = {
/** Maximum number of results to return per page */
Expand Down Expand Up @@ -77,14 +77,14 @@ export type AddSafeDelegateProps = {
safeAddress?: string
delegateAddress: string
delegatorAddress: string
signer: Signer
signer: WalletClient<Transport, Chain, Account>
label: string
}

export type DeleteSafeDelegateProps = {
delegateAddress: string
delegatorAddress: string
signer: Signer
signer: WalletClient<Transport, Chain, Account>
}

export type SafeDelegateResponse = {
Expand Down Expand Up @@ -248,19 +248,20 @@ export type AddMessageProps = {
}

export type GetSafeMessageListProps = {
/** Which field to use when ordering the results. It can be: `created`, `modified` (default: `-created`) */
ordering?: string
} & ListOptions

export type EIP712TypedData = {
domain: TypedDataDomain
types: TypedDataField
types: TypedDataParameter
message: Record<string, unknown>
}

export type GetSafeOperationListProps = {
/** Address of the Safe to get SafeOperations for */
safeAddress: string
/** Which field to use when ordering the results */
/** Which field to use when ordering the results. It can be: `user_operation__nonce`, `created` (default: `-user_operation__nonce`) */
ordering?: string
} & ListOptions

Expand Down
2 changes: 1 addition & 1 deletion packages/api-kit/src/utils/safeOperation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SafeOperation } from '@safe-global/safe-core-sdk-types'
import { SafeOperation } from '@safe-global/types-kit'

export const getAddSafeOperationProps = async (safeOperation: SafeOperation) => {
const userOperation = safeOperation.toUserOperation()
Expand Down
17 changes: 13 additions & 4 deletions packages/api-kit/src/utils/signDelegate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Signer } from 'ethers'
import { Chain, Account, Transport, WalletClient } from 'viem'

export async function signDelegate(signer: Signer, delegateAddress: string, chainId: bigint) {
export async function signDelegate(
walletClient: WalletClient<Transport, Chain, Account>,
delegateAddress: string,
chainId: bigint
) {
const domain = {
name: 'Safe Transaction Service',
version: '1.0',
chainId: chainId
chainId: Number(chainId)
}

const types = {
Expand All @@ -16,5 +20,10 @@ export async function signDelegate(signer: Signer, delegateAddress: string, chai

const totp = Math.floor(Date.now() / 1000 / 3600)

return signer.signTypedData(domain, types, { delegateAddress, totp })
return walletClient.signTypedData({
domain,
types,
primaryType: 'Delegate',
message: { delegateAddress, totp }
})
}
2 changes: 1 addition & 1 deletion packages/api-kit/tests/e2e/addMessageSignature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Safe, {
SigningMethod,
buildContractSignature
} from '@safe-global/protocol-kit'
import { SafeMessage } from '@safe-global/safe-core-sdk-types'
import { SafeMessage } from '@safe-global/types-kit'
import SafeApiKit from '@safe-global/api-kit/index'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
Expand Down
Loading

0 comments on commit 57d3c99

Please sign in to comment.