Skip to content

Commit

Permalink
Merge branch 'development' into Abitype-1_3_0-safe-contract
Browse files Browse the repository at this point in the history
  • Loading branch information
dasanra committed Dec 27, 2023
2 parents f2ec327 + d78797c commit 42f6535
Show file tree
Hide file tree
Showing 48 changed files with 1,201 additions and 1,870 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ module.exports = {
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module' // Allows for the use of imports
},
rules: {
'@typescript-eslint/no-explicit-any': ['warn'] // any returns linter error by default.
}
}
2 changes: 0 additions & 2 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
- development
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
jobs:
test:
runs-on: ubuntu-latest
Expand Down
39 changes: 6 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
- development
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -30,37 +28,12 @@ jobs:
- name: Test
run: yarn test

- name: Account Abstraction Kit coverage
- name: Upload coverage report
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: packages/account-abstraction-kit
file: packages/account-abstraction-kit/coverage/lcov.info

- name: Auth Kit coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: packages/auth-kit
file: packages/auth-kit/coverage/lcov.info

- name: OnRamp Kit coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: packages/onramp-kit
file: packages/onramp-kit/coverage/lcov.info

- name: Relay Kit coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: packages/relay-kit
file: packages/relay-kit/coverage/lcov.info

- name: Api Kit coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-path: packages/api-kit
file: packages/api-kit/coverage/lcov.info
files: packages/account-abstraction-kit/coverage/lcov.info
packages/api-kit/coverage/lcov.info
packages/auth-kit/coverage/lcov.info
packages/onramp-kit/coverage/lcov.info
packages/relay-kit/coverage/lcov.info
2 changes: 0 additions & 2 deletions .github/workflows/test_contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- main
- development
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
jobs:
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 0 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"packages": ["packages/*"],
"version": "independent",
"useWorkspaces": true,
"command": {
"run": {
"npmClient": "yarn"
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
"author": "Safe (https://safe.global)",
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.7",
"@types/jest": "^29.5.11",
"@types/node": "^18.18.8",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"jest": "^29.7.0",
"lerna": "^6.6.2",
"lint-staged": "^13.3.0",
"prettier": "^2.8.8",
"lerna": "^7.4.2",
"lint-staged": "^14.0.1",
"prettier": "^3.1.1",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"tsc-alias": "^1.8.8",
"typescript": "^5.3.2"
"typescript": "^5.3.3"
},
"lint-staged": {
"./packages/**/*.{js,jsx,ts,tsx}": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const SafeMock = Safe as jest.MockedClass<typeof Safe>
describe('AccountAbstraction', () => {
const ethersAdapter = {
getSignerAddress: jest.fn(),
isContractDeployed: jest.fn()
isContractDeployed: jest.fn(),
getChainId: jest.fn()
}
const signerAddress = '0xSignerAddress'
const predictSafeAddress = '0xPredictSafeAddressMock'
Expand Down
1 change: 1 addition & 0 deletions packages/account-abstraction-kit/src/AccountAbstraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AccountAbstraction {

const safeAddress = await predictSafeAddress({
ethAdapter: this.#ethAdapter,
chainId: await this.#ethAdapter.getChainId(),
safeAccountConfig
})

Expand Down
3 changes: 1 addition & 2 deletions packages/api-kit/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
INFURA_KEY=
MNEMONIC=
PK=
PK=
10 changes: 3 additions & 7 deletions packages/api-kit/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import yargs from 'yargs'

import 'tsconfig-paths/register'

const argv = yargs
yargs
.option('network', {
type: 'string',
default: 'hardhat'
Expand All @@ -15,7 +15,7 @@ const argv = yargs
.version(false).argv

dotenv.config()
const { INFURA_KEY, MNEMONIC, PK, TESTS_PATH } = process.env
const { MNEMONIC, PK, TESTS_PATH } = process.env
const DEFAULT_MNEMONIC =
'myth like bonus scare over problem client lizard pioneer submit female collect'

Expand All @@ -28,10 +28,6 @@ if (PK) {
}
}

if (['goerli'].includes(argv.network) && INFURA_KEY === undefined) {
throw new Error(`Could not find Infura key in env, unable to connect to network ${argv.network}`)
}

const config: HardhatUserConfig = {
defaultNetwork: 'goerli',
paths: {
Expand All @@ -45,7 +41,7 @@ const config: HardhatUserConfig = {
},
goerli: {
...sharedNetworkConfig,
url: `https://goerli.infura.io/v3/${INFURA_KEY}`
url: 'https://rpc.ankr.com/eth_goerli'
}
},
//@ts-expect-error Type not found
Expand Down
11 changes: 5 additions & 6 deletions packages/api-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,21 @@
],
"homepage": "https://github.com/safe-global/safe-core-sdk#readme",
"devDependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.4 ",
"@nomicfoundation/hardhat-ethers": "^3.0.5",
"@nomiclabs/hardhat-web3": "^2.0.0",
"@types/chai": "^4.3.9",
"@types/chai": "^4.3.11",
"@types/chai-as-promised": "^7.1.8",
"@types/mocha": "^10.0.3",
"@types/mocha": "^10.0.6",
"@types/node-fetch": "^2.6.9",
"@types/sinon-chai": "^3.2.11",
"@types/yargs": "^16.0.7",
"@types/yargs": "^17.0.32",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"hardhat": "^2.19.0",
"hardhat": "^2.19.3",
"mocha": "^10.2.0",
"semver": "^7.5.4",
"sinon": "^14.0.2",
"sinon-chai": "^3.7.0",
"ts-generator": "^0.1.1",
"tsconfig-paths": "^4.2.0",
"yargs": "^17.7.2"
},
Expand Down
4 changes: 1 addition & 3 deletions packages/api-kit/src/SafeApiKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,7 @@ class SafeApiKit {
const { address } = this.#getEip3770Address(safeAddress)
const nonce = currentNonce ? currentNonce : (await this.getSafeInfo(address)).nonce
return sendRequest({
url: `${
this.#txServiceBaseUrl
}/v1/safes/${address}/multisig-transactions/?executed=false&nonce__gte=${nonce}`,
url: `${this.#txServiceBaseUrl}/v1/safes/${address}/multisig-transactions/?executed=false&nonce__gte=${nonce}`,
method: HttpMethod.Get
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/api-kit/tests/e2e/decodeData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('decodeData', () => {
const data = '0x1'
await chai
.expect(safeApiKit.decodeData(data))
.to.be.rejectedWith('Ensure this field has at least 1 hexadecimal chars (not counting 0x).')
.to.be.rejectedWith('Ensure this field has at least 4 hexadecimal chars (not counting 0x).')
})

it('should fail if the function selector is not found', async () => {
Expand Down
15 changes: 6 additions & 9 deletions packages/api-kit/tests/e2e/getMultisigTransactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,16 @@ describe('getMultisigTransactions', () => {

it('should return an empty list if there are no multisig transactions', async () => {
const safeAddress = '0x3e04a375aC5847C690A7f2fF54b45c59f7eeD6f0' // Safe without multisig transactions
const safeMultisigTransactionListResponse = await safeApiKit.getMultisigTransactions(
safeAddress
)
const safeMultisigTransactionListResponse =
await safeApiKit.getMultisigTransactions(safeAddress)
chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(0)
chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(0)
})

it('should return the list of multisig transactions', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with multisig transactions
const safeMultisigTransactionListResponse = await safeApiKit.getMultisigTransactions(
safeAddress
)
const safeMultisigTransactionListResponse =
await safeApiKit.getMultisigTransactions(safeAddress)
chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(12)
chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(12)
safeMultisigTransactionListResponse.results.map((transaction) => {
Expand All @@ -53,9 +51,8 @@ describe('getMultisigTransactions', () => {
it('should return the list of multisig transactions EIP-3770', async () => {
const safeAddress = '0x9D1E7371852a9baF631Ea115b9815deb97cC3205' // Safe with multisig transactions
const eip3770SafeAddress = `${config.EIP_3770_PREFIX}:${safeAddress}`
const safeMultisigTransactionListResponse = await safeApiKit.getMultisigTransactions(
eip3770SafeAddress
)
const safeMultisigTransactionListResponse =
await safeApiKit.getMultisigTransactions(eip3770SafeAddress)
chai.expect(safeMultisigTransactionListResponse.count).to.be.equal(12)
chai.expect(safeMultisigTransactionListResponse.results.length).to.be.equal(12)
safeMultisigTransactionListResponse.results.map((transaction) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-kit/tests/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
CHAIN_ID: 5n,
BASE_URL: 'https://safe-transaction-goerli.safe.global',
JSON_RPC: `https://goerli.infura.io/v3/${process.env.INFURA_KEY}`,
JSON_RPC: 'https://rpc.ankr.com/eth_goerli',
EIP_3770_PREFIX: 'gor'
}

Expand Down
2 changes: 1 addition & 1 deletion packages/auth-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@safe-global/auth-kit",
"version": "2.0.0-alpha.10",
"version": "2.0.0",
"description": "Authentication library for web2 logins",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/onramp-kit/example/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@monerium/sdk": "^2.6.5",
"@monerium/sdk": "^2.9.0",
"@mui/material": "^5.14.17",
"@safe-global/auth-kit": "file:../../../auth-kit",
"@safe-global/onramp-kit": "file:../../",
Expand Down
13 changes: 9 additions & 4 deletions packages/onramp-kit/example/client/src/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ export const AuthContext = createContext<AuthContextType>({
selectedSafe: '',
provider: null
})

const STORED_SAFE = 'selected_safe'
const AuthProvider = ({ children }: AuthContextProviderProps) => {
const [safeAuthPack, setSafeAuthPack] = useState<SafeAuthPack>()
const [isAuthenticated, setIsAuthenticated] = useState(!!safeAuthPack?.isAuthenticated)
const [safeAuthSignInResponse, setSafeAuthSignInResponse] = useState<AuthKitSignInData>()
const [provider, setProvider] = useState<ethers.Eip1193Provider | null>()
const [selectedSafe, setSelectedSafe] = useState('')

const storedSafe = sessionStorage.getItem(STORED_SAFE)

useEffect(() => {
;(async () => {
const authPack = new SafeAuthPack()
Expand All @@ -52,7 +54,7 @@ const AuthProvider = ({ children }: AuthContextProviderProps) => {
setIsAuthenticated(true)

if (signInInfo.safes && signInInfo.safes.length > 0) {
setSelectedSafe(signInInfo?.safes[0])
setSelectedSafe(storedSafe || signInInfo?.safes[0])
}
}
})
Expand All @@ -73,7 +75,7 @@ const AuthProvider = ({ children }: AuthContextProviderProps) => {
setIsAuthenticated(true)

if (signInInfo?.safes && signInInfo.safes.length > 0) {
setSelectedSafe(signInInfo?.safes[0])
setSelectedSafe(storedSafe || signInInfo?.safes[0])
}
}

Expand All @@ -96,7 +98,10 @@ const AuthProvider = ({ children }: AuthContextProviderProps) => {
logIn,
logOut,
selectedSafe,
setSelectedSafe
setSelectedSafe: (safe) => {
sessionStorage.setItem(STORED_SAFE, safe)
setSelectedSafe(safe)
}
}}
>
{children}
Expand Down
Loading

0 comments on commit 42f6535

Please sign in to comment.