Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Switch to SIP-030 #403

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b42fb6d
chore: partial
janniks Jan 14, 2025
f7fbea2
chore: partial
janniks Jan 14, 2025
e5b85f9
chore: add more partial, all methods
janniks Jan 15, 2025
98173fa
chore: partial compiling
janniks Jan 16, 2025
7b0bf69
chore: add more backwards comp, compiles
janniks Jan 18, 2025
bfc7287
chore: update error handling and option casting
janniks Jan 18, 2025
caacf17
chore: add xverse overrides
janniks Jan 20, 2025
b769cf9
fix: add missing AppConfig export
janniks Jan 20, 2025
3c1c778
fix: remove stacks/auth remnants
janniks Jan 20, 2025
2886e94
fix: update xverse strictness
janniks Jan 21, 2025
abd2189
fix: make auth options less strict
janniks Jan 21, 2025
d780b0c
chore: update imports
janniks Jan 21, 2025
cab6b28
chore: add temporary eslint ignore line
janniks Jan 21, 2025
ab8b769
fix: update usersession disconnect behavior
janniks Jan 21, 2025
f9d9c45
fix: address pr feedback
janniks Jan 22, 2025
dbdd993
fix!: rename persistselection property
janniks Jan 22, 2025
9ba4342
refactor: improve error handling
janniks Jan 22, 2025
e685b75
chore: rename to uppercase
janniks Jan 22, 2025
656da16
refactor: simplify object returns
janniks Jan 22, 2025
f101055
docs: update changelog
janniks Jan 22, 2025
4b29983
docs: update readme
janniks Jan 23, 2025
80753a7
docs: add provider push
janniks Jan 23, 2025
02d8e8a
docs: add identity check
janniks Jan 23, 2025
6c44538
fix: update authenticate provider handling
janniks Jan 24, 2025
cd03207
chore: remove import
janniks Jan 24, 2025
162e427
fix: auto encode and decode base64 for psbt
janniks Jan 24, 2025
352a540
fix: update caps for sighash
janniks Jan 29, 2025
cc3d5e1
fix: add fordefi default provider
janniks Jan 29, 2025
c6778be
test: update storybook test dapp
janniks Jan 29, 2025
f3096a1
fix: add fordefi to override list
janniks Jan 30, 2025
3c2c6a6
fix: update clarity values parsing
janniks Jan 30, 2025
9c81ff0
chore: add bigint tojson
janniks Feb 3, 2025
f8c6c15
ci: add beta deploy
janniks Feb 3, 2025
f4692ec
Merge branch 'main' into feat/switch-to-sip-030
janniks Feb 10, 2025
c6ab376
fix: add btcAddress to legacy profile
janniks Feb 10, 2025
d7965ac
test: fix demo app
janniks Feb 10, 2025
0960489
chore: update lerna
janniks Feb 10, 2025
9f1d862
chore: add optional to package lock
janniks Feb 10, 2025
b00f052
chore: update lock based on file on main
janniks Feb 10, 2025
f316d49
chore: add literal union
janniks Feb 10, 2025
ba166a5
fix: remove jsontokens dependency
janniks Feb 10, 2025
8a0b7bc
fix: update error types and allow error in onCancel
janniks Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/bright-pumpkins-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@stacks/connect-react': major
'@stacks/connect': major
---

Switch to new RPC API with SIP-030

BREAKING CHANGE:

Adds the new `request` method to the `@stacks/connect` package.
Which is the default way of interacting with Bitcoin and Stacks wallets.
This update needs a slightly breaking change to the `showXyz` and `openXyz` methods.

- ADDED `request` (UI) and `requestRaw` for calling wallet RPC methods
- UPDATED `SessionData` and `UserSession` to only expose a light `UserData` with `profile.stxAddress`
- UPDATED `StacksProvider` to only have a `request` method
- REMOVED `BlockstackProvider`, `StacksProvider`
10 changes: 10 additions & 0 deletions .changeset/lovely-jobs-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@stacks/connect-ui': major
---

Update UI properties

BREAKING CHANGE:

- RENAMED `persistSelection` to `persistWalletSelect`
- REMOVED `shouldUsePopup` from `@stacks/connect-ui`
23 changes: 13 additions & 10 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,30 @@ jobs:
- name: Get git commit
id: git-commit
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
- name: print preid
env:
BRANCH: ${{ steps.git-branch.outputs.branch }}
SHA: ${{ steps.git-commit.outputs.sha }}
run: echo $BRANCH.$SHA
- name: Set preid
id: preid
run: |
if [ "${{ steps.git-branch.outputs.branch }}" = "beta" ]; then
echo "preid=beta" >> "$GITHUB_OUTPUT"
else
echo "preid=alpha.${{ steps.git-commit.outputs.sha }}" >> "$GITHUB_OUTPUT"
fi
- name: Setup git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Publish to NPM
env:
BRANCH: ${{ steps.git-branch.outputs.branch }}
SHA: ${{ steps.git-commit.outputs.sha }}
run: npx lerna publish prepatch --preid alpha.$SHA --dist-tag $BRANCH --yes --no-push
- name: Get alpha package versions
id: alpha
PREID: ${{ steps.preid.outputs.preid }}
run: npx lerna publish prepatch --preid $PREID --dist-tag $BRANCH --yes --no-push
- name: Get package versions
id: versions
run: |
echo "connect=$(cat packages/connect/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
echo "connectreact=$(cat packages/connect-react/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
echo "connectui=$(cat packages/connect-ui/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
- uses: janniks/pull-request-fixed-header@v1.0.1
with:
header: "> This PR was published to npm with the alpha versions:\n> - connect `npm install @stacks/connect@${{ steps.alpha.outputs.connect }} --save-exact`\n> - connect-react `npm install @stacks/connect-react@${{ steps.alpha.outputs.connectreact }} --save-exact`\n> - connect-ui `npm install @stacks/connect-ui@${{ steps.alpha.outputs.connectui }} --save-exact`"
header: "> This PR was published to npm with versions:\n> - connect `npm install @stacks/connect@${{ steps.versions.outputs.connect }} --save-exact`\n> - connect-react `npm install @stacks/connect-react@${{ steps.versions.outputs.connectreact }} --save-exact`\n> - connect-ui `npm install @stacks/connect-ui@${{ steps.versions.outputs.connectui }} --save-exact`"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99 changes: 80 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,75 @@ This repository includes three packages:
- [`@stacks/connect-react`](./packages/connect-react): A wrapper library for making `@stacks/connect` use in React even easier
- [`@stacks/connect-ui`](./packages/connect-ui): A web-component UI for displaying an intro modal in Stacks web-apps during authentication _(used in the background by `@stacks/connect`)_.

## 🌎 More Information

The [Stacks documentation website](https://docs.stacks.co/build-apps/overview) includes more examples for building apps using Connect.

It also includes guides for various aspects of Stacks application development:

- [Authentication](https://docs.stacks.co/build-apps/references/authentication)
- [Transactions](https://docs.stacks.co/understand-stacks/technical-specs#transactions)
- [Data storage](https://docs.stacks.co/build-apps/references/gaia#understand-data-storage)

## 🐛 Bugs and feature requests

If you encounter a bug or have a feature request, we encourage you to follow the steps below:

1. **Search for existing issues:** Before submitting a new issue, please search [existing and closed issues](https://github.com/hirosystems/connect/issues) to check if a similar problem or feature request has already been reported.
1. **Open a new issue:** If it hasn't been addressed, please [open a new issue](https://github.com/hirosystems/connect/issues/new/choose). Choose the appropriate issue template and provide as much detail as possible, including steps to reproduce the bug or a clear description of the requested feature.
1. **Evaluation SLA:** Our team reads and evaluates all the issues and pull requests. We are avaliable Monday to Friday and we make a best effort to respond within 7 business days.

Please **do not** use the issue tracker for personal support requests or to ask for the status of a transaction. You'll find help at the [#stacks-js Discord channel](https://stacks.chat/).
## 🛠️ Wallet Implementation Guide

Wallets implement a "Provider" interface.
The latest spec uses a simple JS Object exposing a `.request(method: string, params?: object)` method.

Pseudo-code:

```ts
window.MyProvider = {
async request(method, params) {
// Somehow communicate with the wallet (e.g. via events)

// Recommendation: Create a JSON RPC 2.0 request object
// https://www.jsonrpc.org/specification

return Promise.resolve({
// Respond with a JSON RPC 2.0 response object
id: crypto.randomUUID(), // required, same as request
jsonrpc: '2.0', // required

// `.result` is required on success
result: {
// object matching specified RPC methods
},

// `.error` is required on error
error: {
// Use existing codes from https://www.jsonrpc.org/specification#error_object
code: number, // required, integer
message: string, // recommended, single sentence
data: object, // optional
},
});
},
isMyWallet: true, // optional, a way of identifying the wallet for developers
};

window.wbip_providers = window.wbip_providers || [];
window.wbip_providers.push({
// `WbipProvider` type
/** The global "path" of the provider (e.g. `"MyProvider"` if registered at `window.MyProvider`) */
id: 'MyProvider',
/** The name of the provider, as displayed to the user */
name: 'My Wallet';
/** The data URL of an image to show (e.g. `data:image/png;base64,iVBORw0...`) @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs */
icon?: 'data:image/png;base64,iVBORw0...';
/** Web URL of the provider */
webUrl?: 'https://mywallet.example.com';

// Addional URLs
chromeWebStoreUrl?: string;
mozillaAddOnsUrl?: string;
googlePlayStoreUrl?: string;
iOSAppStoreUrl?: string;
});
```

### JSON RPC 2.0

Wallets may add their own unstandardized methods.
However, the minimum recommended methods are:

- `getAddresses` [WBIP](https://wbips.netlify.app/request_api/getAddresses)
- `signPsbt` [WBIP](https://wbips.netlify.app/request_api/signPsbt)
- `stx_getAddresses` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)
- `stx_transferStx` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)
- `stx_callContract` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)
- `stx_signMessage` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)
- `stx_signStructuredMessage` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)

## 🎁 Contribute

Expand All @@ -59,3 +109,14 @@ Join our community and stay connected with the latest updates and discussions:
- [Join our Discord community chat](https://stacks.chat/) to engage with other users, ask questions, and participate in discussions.
- [Visit hiro.so](https://www.hiro.so/) for updates and subcribing to the mailing list.
- Follow [Hiro on Twitter.](https://twitter.com/hirosystems)

### MIGRATION TODO

#### TODO

- Add `PostConditionModeName` to all options (new and old) — This might have been missing since the v7 release.
- Strip unserializable fields from RawLegacy wrapper just in case.
- Remove exports from LEGACY_XYZ
- Make hex to base64 for psbt

Search for the below and replace with inline return.
Loading
Loading