Skip to content

Commit

Permalink
chore: Rename safe-kit to sdk-starter-kit (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanra authored Aug 19, 2024
1 parent 9f585ec commit 61284fb
Show file tree
Hide file tree
Showing 36 changed files with 75 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/sdk-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: packages/safe-kit/coverage/lcov.info
packages/api-kit/coverage/lcov.info
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
3 changes: 2 additions & 1 deletion packages/relay-kit/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"composite": true,
"outDir": "dist"
},
"include": ["src/**/*"]
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Safe Kit
# SDK Starter Kit

[![npm Version](https://badge.fury.io/js/%40safe-global%2Faccount-abstraction-kit-poc.svg)](https://badge.fury.io/js/%40safe-global%2Faccount-abstraction-kit-poc)
[![npm Version](https://badge.fury.io/js/%40safe-global%2Fsdk-starter-kit.svg)](https://badge.fury.io/js/%40safe-global%2Fsdk-starter-kit)
[![GitHub Release](https://img.shields.io/github/release/safe-global/safe-core-sdk.svg?style=flat)](https://github.com/safe-global/safe-core-sdk/releases)
[![GitHub](https://img.shields.io/github/license/safe-global/safe-core-sdk)](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md)

Expand All @@ -18,8 +18,8 @@ Description TBD
Install the package with yarn or npm:

```bash
yarn add @safe-global/safe-kit
npm install @safe-global/safe-kit
yarn add @safe-global/sdk-starter-kit
npm install @safe-global/sdk-starter-kit
```

## Need Help or Have Questions?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const config = {
moduleNameMapper: {
'^@safe-global/protocol-kit/(.*)$': '<rootDir>/../protocol-kit/src/$1',
'^@safe-global/relay-kit/(.*)$': '<rootDir>/../relay-kit/src/$1',
'^@safe-global/safe-kit/(.*)$': '<rootDir>/src/$1'
'^@safe-global/sdk-starter-kit/(.*)$': '<rootDir>/src/$1'
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"name": "@safe-global/safe-kit",
"name": "@safe-global/sdk-starter-kit",
"version": "1.0.0",
"description": "Safe Kit is a library that provides a set of tools to interact with the Safe Protocol.",
"description": "SDK that provides the basic tools to interact with the Safe Smart Account.",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
"keywords": [
"Safe",
"Ethereum",
"Wallet",
"Safe",
"Smart Account",
"Account Abstraction",
"SDK"
],
"scripts": {
"unbuild": "rimraf dist",
"build": "yarn unbuild && tsc && tsc-alias",
"build": "yarn unbuild && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"",
"format": "prettier --write \"*/**/*.{js,json,md,ts}\"",
"test": "jest src --coverage"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import {
sendTransaction,
proposeTransaction,
waitSafeTxReceipt
} from '@safe-global/safe-kit/utils'
import { SafeClientTxStatus } from '@safe-global/safe-kit/constants'
} from '@safe-global/sdk-starter-kit/utils'
import { SafeClientTxStatus } from '@safe-global/sdk-starter-kit/constants'
import {
ConfirmTransactionProps,
SafeClientResult,
SendTransactionProps
} from '@safe-global/safe-kit/types'
} from '@safe-global/sdk-starter-kit/types'

/**
* @class
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import SafeApiKit, {
SafeMessageListResponse
} from '@safe-global/api-kit'
import { SafeMessage } from '@safe-global/safe-core-sdk-types'
import { createSafeClientResult, sendTransaction } from '@safe-global/safe-kit/utils'
import { SafeClientTxStatus } from '@safe-global/safe-kit/constants'
import { createSafeClientResult, sendTransaction } from '@safe-global/sdk-starter-kit/utils'
import { SafeClientTxStatus } from '@safe-global/sdk-starter-kit/constants'
import {
ConfirmOffChainMessageProps,
SafeClientResult,
SendOffChainMessageProps
} from '@safe-global/safe-kit/types'
} from '@safe-global/sdk-starter-kit/types'

/**
* @class
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ListOptions, SafeMessageListResponse } from '@safe-global/api-kit'

import { SafeClient } from '@safe-global/safe-kit/SafeClient'
import { SafeMessageClient } from '@safe-global/safe-kit/extensions/messages/SafeMessageClient'
import { SafeClient } from '@safe-global/sdk-starter-kit/SafeClient'
import { SafeMessageClient } from '@safe-global/sdk-starter-kit/extensions/messages/SafeMessageClient'
import {
ConfirmOffChainMessageProps,
SafeClientResult,
SendOffChainMessageProps
} from '@safe-global/safe-kit/types'
} from '@safe-global/sdk-starter-kit/types'

/**
* Extend the SafeClient with the ability to use off-chain messages
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { hashSafeMessage } from '@safe-global/protocol-kit'
import { OperationType } from '@safe-global/safe-core-sdk-types'

import { SafeClient } from '@safe-global/safe-kit/SafeClient'
import { SafeClientResult, SendOnChainMessageProps } from '@safe-global/safe-kit/types'
import { SafeClient } from '@safe-global/sdk-starter-kit/SafeClient'
import { SafeClientResult, SendOnChainMessageProps } from '@safe-global/sdk-starter-kit/types'

/**
* Extend the SafeClient with the ability to use on-chain messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import Safe, { buildSignatureBytes } from '@safe-global/protocol-kit'
import SafeApiKit, { ListOptions, GetSafeOperationListResponse } from '@safe-global/api-kit'
import { Safe4337Pack } from '@safe-global/relay-kit'

import { createSafeClientResult } from '@safe-global/safe-kit/utils'
import { SafeClientTxStatus } from '@safe-global/safe-kit/constants'
import { createSafeClientResult } from '@safe-global/sdk-starter-kit/utils'
import { SafeClientTxStatus } from '@safe-global/sdk-starter-kit/constants'
import {
ConfirmSafeOperationProps,
SafeClientResult,
SendSafeOperationProps
} from '@safe-global/safe-kit/types'
} from '@safe-global/sdk-starter-kit/types'

/**
* @class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { PredictedSafeProps } from '@safe-global/protocol-kit'
import { GetSafeOperationListResponse, ListOptions } from '@safe-global/api-kit'
import { PaymasterOptions, Safe4337Pack } from '@safe-global/relay-kit'

import { SafeClient } from '@safe-global/safe-kit/SafeClient'
import { SafeOperationClient } from '@safe-global/safe-kit/extensions/safe-operations/SafeOperationClient'
import { BundlerOptions } from '@safe-global/safe-kit/extensions/safe-operations/types'
import { SafeClient } from '@safe-global/sdk-starter-kit/SafeClient'
import { SafeOperationClient } from '@safe-global/sdk-starter-kit/extensions/safe-operations/SafeOperationClient'
import { BundlerOptions } from '@safe-global/sdk-starter-kit/extensions/safe-operations/types'
import {
ConfirmSafeOperationProps,
SafeClientResult,
SendSafeOperationProps
} from '@safe-global/safe-kit/types'
} from '@safe-global/sdk-starter-kit/types'

/**
* Extend the SafeClient with the ability to use a bundler and a paymaster
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Safe from '@safe-global/protocol-kit'
import SafeApiKit from '@safe-global/api-kit'

import { SafeClient } from '@safe-global/safe-kit/SafeClient'
import { isValidAddress, isValidSafeConfig } from '@safe-global/safe-kit/utils'
import { SafeKitConfig } from '@safe-global/safe-kit/types'
import { SafeClient } from '@safe-global/sdk-starter-kit/SafeClient'
import { isValidAddress, isValidSafeConfig } from '@safe-global/sdk-starter-kit/utils'
import { SdkStarterKitConfig } from '@safe-global/sdk-starter-kit/types'

/**
* Initializes a Safe client with the given configuration options.
*
* @param config - The Safe client configuration options.
* @returns A Safe client instance.
*/
export async function createSafeClient(config: SafeKitConfig): Promise<SafeClient> {
export async function createSafeClient(config: SdkStarterKitConfig): Promise<SafeClient> {
const protocolKit = await getProtocolKitInstance(config)
const apiKit = await getApiKitInstance(protocolKit)

Expand All @@ -23,10 +23,10 @@ export async function createSafeClient(config: SafeKitConfig): Promise<SafeClien
/**
* Get the Safe protocol kit instance.
*
* @param config - The Safe kit configuration options.
* @param config - The SDK Starter kit configuration options.
* @returns A protocolKit instance.
*/
async function getProtocolKitInstance(config: SafeKitConfig): Promise<Safe> {
async function getProtocolKitInstance(config: SdkStarterKitConfig): Promise<Safe> {
if (config.safeAddress && isValidAddress(config.safeAddress)) {
// If the safe already exist
return Safe.init({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
MetaTransactionData
} from '@safe-global/safe-core-sdk-types'
import { IFeeEstimator } from '@safe-global/relay-kit'
import { SafeClientTxStatus } from '@safe-global/safe-kit/constants'
import { SafeClientTxStatus } from '@safe-global/sdk-starter-kit/constants'

export type SendTransactionProps = {
transactions: TransactionBase[]
Expand Down Expand Up @@ -46,22 +46,23 @@ export type SafeConfig = {
saltNonce?: string
}

export type ExistingSafeKitConfig = {
export type ExistingSafeConfig = {
safeAddress?: string
safeOptions?: never
}

export type PredictedSafeKitConfig = {
export type PredictedSafeConfig = {
safeAddress?: never
safeOptions?: SafeConfig
}

export type SafeKitRootConfig = {
export type SdkStarterKitRootConfig = {
provider: SafeProvider['provider']
signer: SafeProvider['signer']
}

export type SafeKitConfig = SafeKitRootConfig & (ExistingSafeKitConfig | PredictedSafeKitConfig)
export type SdkStarterKitConfig = SdkStarterKitRootConfig &
(ExistingSafeConfig | PredictedSafeConfig)

export type SafeClientResult = {
safeAddress: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { validateEthereumAddress } from '@safe-global/protocol-kit'
import { TransactionResult } from '@safe-global/safe-core-sdk-types'
import { ContractTransactionReceipt, TransactionResponse } from 'ethers'

import { MESSAGES, SafeClientTxStatus } from '@safe-global/safe-kit/constants'
import { SafeClientResult, SafeConfig } from '@safe-global/safe-kit/types'
import { MESSAGES, SafeClientTxStatus } from '@safe-global/sdk-starter-kit/constants'
import { SafeClientResult, SafeConfig } from '@safe-global/sdk-starter-kit/types'

export const isValidAddress = (address: string): boolean => {
try {
Expand Down
9 changes: 9 additions & 0 deletions packages/sdk-starter-kit/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.settings.json",
"compilerOptions": {
"composite": true,
"outDir": "dist"
},
"include": ["src/**/*"],
"exclude": ["src/**/*.test.ts", "src/**/*.test-d.ts"]
}
File renamed without changes.
15 changes: 9 additions & 6 deletions playground/config/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ const playgroundRelayKitPaths = {
'relay-kit/usdc-transfer-4337-sponsored-counterfactual'
}

const playgroundSafeKitPaths = {
'send-transactions': 'safe-kit/send-transactions',
'send-on-chain-message': 'safe-kit/send-on-chain-message',
'send-off-chain-message': 'safe-kit/send-off-chain-message',
'send-safe-operation': 'safe-kit/send-safe-operation'
const playgroundStarterKitPaths = {
'send-transactions': 'sdk-starter-kit/send-transactions',
'send-on-chain-message': 'sdk-starter-kit/send-on-chain-message',
'send-off-chain-message': 'sdk-starter-kit/send-off-chain-message',
'send-safe-operation': 'sdk-starter-kit/send-safe-operation'
}

const path =
playgroundProtocolKitPaths[playInput] ||
playgroundApiKitPaths[playInput] ||
playgroundRelayKitPaths[playInput] ||
playgroundSafeKitPaths[playInput]
playgroundStarterKitPaths[playInput]

function printPlaygrounds(playgroundPaths: Record<string, string>) {
const playgroundKits = Object.keys(playgroundPaths)
Expand All @@ -61,6 +61,9 @@ if (!path) {
console.log('RELAY KIT')
printPlaygrounds(playgroundRelayKitPaths)

console.log('SDK STARTER KIT')
printPlaygrounds(playgroundStarterKitPaths)

process.exit()
}

Expand Down
2 changes: 1 addition & 1 deletion playground/relay-kit/paid-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createSafeClient, SafeClient } from '@safe-global/safe-kit'
import { createSafeClient, SafeClient } from '@safe-global/sdk-starter-kit'
import { GelatoRelayPack } from '@safe-global/relay-kit'
import {
MetaTransactionData,
Expand Down
2 changes: 1 addition & 1 deletion playground/relay-kit/sponsored-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createSafeClient, SafeClient } from '@safe-global/safe-kit'
import { createSafeClient, SafeClient } from '@safe-global/sdk-starter-kit'
import { GelatoRelayPack } from '@safe-global/relay-kit'
import {
MetaTransactionData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SafeClientResult, createSafeClient, offChainMessages } from '@safe-global/safe-kit'
import { SafeClientResult, createSafeClient, offChainMessages } from '@safe-global/sdk-starter-kit'

const OWNER_1_PRIVATE_KEY = ''
const OWNER_2_PRIVATE_KEY = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SafeClientResult, createSafeClient, onChainMessages } from '@safe-global/safe-kit'
import { SafeClientResult, createSafeClient, onChainMessages } from '@safe-global/sdk-starter-kit'

const OWNER_1_PRIVATE_KEY = ''
const OWNER_2_PRIVATE_KEY = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers } from 'ethers'
import { SafeClientResult, createSafeClient, safeOperations } from '@safe-global/safe-kit'
import { SafeClientResult, createSafeClient, safeOperations } from '@safe-global/sdk-starter-kit'
import { generateTransferCallData } from '../utils'

const OWNER_1_PRIVATE_KEY = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SafeClientResult, createSafeClient } from '@safe-global/safe-kit'
import { SafeClientResult, createSafeClient } from '@safe-global/sdk-starter-kit'
import { generateTransferCallData } from '../utils'

const OWNER_1_PRIVATE_KEY = ''
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"files": [],
"references": [
{ "path": "packages/safe-kit" },
{ "path": "packages/api-kit" },
{ "path": "packages/protocol-kit" },
{ "path": "packages/relay-kit" },
{ "path": "packages/auth-kit" },
{ "path": "packages/onramp-kit" },
{ "path": "packages/safe-core-sdk-types" }
{ "path": "packages/safe-core-sdk-types" },
{ "path": "packages/sdk-starter-kit" }
]
}
8 changes: 2 additions & 6 deletions tsconfig.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
"sourceMap": true /* Generates corresponding '.map' file. */,
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
"strictNullChecks": true /* Enable strict null checks. */,
"strictFunctionTypes": true /* Enable strict checking of function types. */,
"strictBindCallApply": true /* Enable strict 'bind', 'call', and 'apply' methods on functions. */,
"strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */,
"noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
"noUnusedParameters": true /* Report errors on unused parameters. */,
Expand All @@ -25,14 +21,14 @@
"resolveJsonModule": true,
"baseUrl": "./",
"paths": {
"@safe-global/safe-kit/*": ["./packages/safe-kit/src/*"],
"@safe-global/api-kit/*": ["./packages/api-kit/src/*"],
"@safe-global/auth-kit/*": ["./packages/auth-kit/src/*"],
"@safe-global/onramp-kit/*": ["./packages/onramp-kit/src/*"],
"@safe-global/protocol-kit/*": ["./packages/protocol-kit/src/*"],
"@safe-global/protocol-kit/hardhat/*": ["./packages/protocol-kit/hardhat/*"],
"@safe-global/relay-kit/*": ["./packages/relay-kit/src/*"],
"@safe-global/safe-core-sdk-types/*": ["./packages/safe-core-sdk-types/src/*"]
"@safe-global/safe-core-sdk-types/*": ["./packages/safe-core-sdk-types/src/*"],
"@safe-global/sdk-starter-kit/*": ["./packages/sdk-starter-kit/src/*"]
}
},
"exclude": ["**/dist", "**/node_modules"]
Expand Down

0 comments on commit 61284fb

Please sign in to comment.