Skip to content

Commit

Permalink
Merge branch 'develop' into virtual-wallet-support
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/core/package.json
#	packages/core/src/main.ts
#	packages/core/src/wallet/filter.ts
#	pnpm-lock.yaml
  • Loading branch information
naorye2 committed Jun 26, 2024
2 parents ece7488 + f9d510d commit 416d888
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 102 deletions.
5 changes: 0 additions & 5 deletions .changeset/dirty-rockets-flash.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/famous-cougars-bathe.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/loud-ladybugs-hide.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/mighty-dancers-itch.md

This file was deleted.

16 changes: 0 additions & 16 deletions .changeset/pre.json

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/rude-tigers-warn.md

This file was deleted.

22 changes: 14 additions & 8 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
name: PR
name: PR integration

on:
pull_request:
branches:
- develop
- master
- develop

jobs:
version:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: checkout code repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/[email protected]

- uses: pnpm/action-setup@v4
with:
version: 8

- name: setup node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
cache: "pnpm"

- name: install dependencies
run: pnpm install
- name: run tests
run: pnpm test

- name: check formatting
run: pnpm format:check

- name: run tests
run: pnpm test
35 changes: 21 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Release

on:
push:
branches:
Expand All @@ -11,45 +12,51 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/[email protected]

- uses: pnpm/action-setup@v4
with:
version: 8

- name: setup node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
cache: "pnpm"

- name: Setup npmrc
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_ACCESS_TOKEN }}" >> .npmrc
- name: install dependencies
run: pnpm install

- name: run tests
run: pnpm test

- name: copy readme to every package
run: echo "./packages/core/ ./packages/ui/" | xargs -n 1 cp README.md

- name: Create Pre-release
if: github.ref == 'refs/heads/develop'
- name: Create Master Release
if: github.ref == 'refs/heads/master'
uses: changesets/action@v1
with:
version: pnpm run version
commit: "chore: pre-release version bump"
title: "Pre-release version bump"
publish: pnpm run publish:next
commit: "chore: version bump"
title: "Master branch version bump"
publish: pnpm run publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
if: github.ref == 'refs/heads/master'
- name: Create Develop Release
if: github.ref == 'refs/heads/develop'
uses: changesets/action@v1
with:
version: pnpm run version
commit: "chore: release version bump"
title: "Release version bump"
publish: pnpm run publish
commit: "chore: version bump"
title: "Develop branch version bump"
publish: pnpm run publish:next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"format": "prettier --ignore-path .gitignore --plugin-search-dir=. --write '**/*.{js,cjs,ts,tsx,svelte,md,yml,json}'",
"format:check": "prettier --ignore-path .gitignore --plugin-search-dir=. --check '**/*.{js,cjs,ts,tsx,svelte,md,yml,json}'",
"prepare": "pnpm run build && husky install",
"publish": "pnpm publish -r --no-git-checks",
"publish:next": "pnpm publish -r --no-git-checks --tag next",
"publish": "pnpm publish -r --no-git-checks && changeset tag",
"publish:next": "pnpm publish -r --no-git-checks --tag next && changeset tag",
"test": "CI=true pnpm run -r test",
"version": "changeset version && pnpm install --lockfile-only"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# get-starknet-core

## 4.0.0-next.5

### Minor Changes

- 5cd8150: Spec update

## 4.0.0-next.4

### Minor Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "get-starknet-core",
"version": "4.0.0-next.4",
"version": "4.0.0",
"keywords": [
"starknet",
"starkware",
Expand Down Expand Up @@ -30,8 +30,8 @@
"test": "vitest"
},
"dependencies": {
"starknet-types": "^0.0.4",
"@module-federation/runtime": "^0.1.2"
"@module-federation/runtime": "^0.1.2",
"@starknet-io/types-js": "^0.7.7"
},
"devDependencies": {
"c8": "^7.12.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/__test__/wallet.mock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import wallets from "../discovery"
import { Permission, type StarknetWindowObject } from "starknet-types"
import { Permission, type StarknetWindowObject } from "@starknet-io/types-js"

type WalletMock = Pick<StarknetWindowObject, "id" | "name" | "icon" | "request">

Expand Down Expand Up @@ -47,7 +47,7 @@ export function makeAuthorized(authorized: boolean) {
request: async (request) => {
switch (request.type) {
case "wallet_getPermissions":
return authorized ? [Permission.Accounts] : []
return authorized ? [Permission.ACCOUNTS] : []
default:
return wallet.request(request)
}
Expand All @@ -62,7 +62,7 @@ export function makeConnected(isConnected: boolean) {
request: async ({ type }) => {
switch (type) {
case "wallet_getPermissions":
return isConnected ? [Permission.Accounts] : []
return isConnected ? [Permission.ACCOUNTS] : []
default:
return []
}
Expand Down
16 changes: 6 additions & 10 deletions packages/core/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@ import {
initiateVirtualWallets,
resolveVirtualWallet,
} from "./wallet/virtualWallets"
import { Permission, type StarknetWindowObject } from "starknet-types"
import { Permission, type StarknetWindowObject } from "@starknet-io/types-js"

export type {
StarknetWindowObject,
AddDeclareTransactionParameters,
AddDeclareTransactionResult,
AddDeployAccountTransactionParameters,
AddDeployAccountTransactionResult,
AddInvokeTransactionParameters,
AddInvokeTransactionResult,
AddStarknetChainParameters,
RequestAccountsParameters,
SwitchStarknetChainParameters,
GetDeploymentDataResult,
AccountDeploymentData,
WatchAssetParameters,
TypedData,
RequestFn,
Expand All @@ -39,9 +37,7 @@ export type {
NetworkChangeEventHandler,
WalletEventHandlers,
WalletEvents,
} from "starknet-types"

export { StarknetChainId, Permission } from "starknet-types"
} from "@starknet-io/types-js"

export { scanObjectForWallets } from "./wallet/scan"
export { isWalletObject } from "./wallet/isWalletObject"
Expand Down Expand Up @@ -131,15 +127,15 @@ export function getStarknet(
await wallet.request({
type: "wallet_requestAccounts",
params: {
silentMode: options?.silentMode,
silent_mode: options?.silent_mode,
},
})

// check for permissions
const permissions = await wallet.request({
const permissions: Permission[] = await wallet.request({
type: "wallet_getPermissions",
})
if (!permissions?.includes(Permission.Accounts)) {
if (!permissions?.includes(Permission.ACCOUNTS)) {
throw new Error("Failed to connect to wallet")
}
lastConnectedStore.set(wallet.id)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Sort } from "./wallet/sort"
import type {
RequestAccountsParameters,
StarknetWindowObject,
} from "starknet-types"
} from "@starknet-io/types-js"

export type { WalletProvider } from "./discovery"

Expand Down
11 changes: 6 additions & 5 deletions packages/core/src/wallet/filter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { WalletProvider } from "../discovery"
import { Permission, type StarknetWindowObject } from "starknet-types"
import { Permission, type StarknetWindowObject } from "@starknet-io/types-js"

export type FilterList = string[]
interface FilterByOptions {
Expand Down Expand Up @@ -34,13 +34,14 @@ export const filterByAuthorized = async (
const preAuthResponses = await Promise.all(
wallets.map(async (wallet) => {
try {
const result = await wallet.request({ type: "wallet_getPermissions" })
return result.includes(Permission.Accounts)
const result: Permission[] = await wallet.request({
type: "wallet_getPermissions",
})
return result.includes(Permission.ACCOUNTS)
} catch {
return false
}
}
),
}),
)
return wallets.filter((_, i) => preAuthResponses[i])
}
2 changes: 1 addition & 1 deletion packages/core/src/wallet/scan.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StarknetWindowObject } from "starknet-types"
import type { StarknetWindowObject } from "@starknet-io/types-js"

export function scanObjectForWallets(
obj: Record<string, any>,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/wallet/sort.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { WalletProvider } from "../discovery"
import { shuffle } from "../utils"
import { type StarknetWindowObject } from "starknet-types"
import { type StarknetWindowObject } from "@starknet-io/types-js"

export type Sort = string[] | "random" | null | undefined

Expand Down
4 changes: 2 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "get-starknet",
"version": "4.0.0-next.2",
"version": "4.0.0",
"keywords": [
"starknet",
"starkware",
Expand Down Expand Up @@ -31,7 +31,7 @@
},
"dependencies": {
"bowser": "^2.11.0",
"get-starknet-core": "workspace:^4.0.0-next.2"
"get-starknet-core": "workspace:^4.0.0"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.1",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 416d888

Please sign in to comment.