Skip to content

Commit cb82258

Browse files
authored
feat!: Switch to SIP-030 (#403)
* chore: partial * chore: partial * chore: add more partial, all methods * chore: partial compiling * chore: add more backwards comp, compiles * chore: update error handling and option casting * chore: add xverse overrides * fix: add missing AppConfig export * fix: remove stacks/auth remnants * fix: update xverse strictness * fix: make auth options less strict * chore: update imports * chore: add temporary eslint ignore line * fix: update usersession disconnect behavior * fix: address pr feedback * fix!: rename persistselection property * refactor: improve error handling * chore: rename to uppercase * refactor: simplify object returns * docs: update changelog * docs: update readme * docs: add provider push * docs: add identity check * fix: update authenticate provider handling * chore: remove import * fix: auto encode and decode base64 for psbt * fix: update caps for sighash * fix: add fordefi default provider * test: update storybook test dapp * fix: add fordefi to override list * fix: update clarity values parsing * chore: add bigint tojson * ci: add beta deploy * fix: add btcAddress to legacy profile * test: fix demo app * chore: update lerna * chore: add optional to package lock * chore: update lock based on file on main * chore: add literal union * fix: remove jsontokens dependency * fix: update error types and allow error in onCancel * fix: update overrides * fix: update param serialization * docs: add new request docs * test: fix story app --------- Co-authored-by: janniks <[email protected]>
1 parent 3dff26e commit cb82258

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3031
-1391
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@stacks/connect-react': major
3+
'@stacks/connect': major
4+
---
5+
6+
Switch to new RPC API with SIP-030
7+
8+
BREAKING CHANGE:
9+
10+
Adds the new `request` method to the `@stacks/connect` package.
11+
Which is the default way of interacting with Bitcoin and Stacks wallets.
12+
This update needs a slightly breaking change to the `showXyz` and `openXyz` methods.
13+
14+
- ADDED `request` (UI) and `requestRaw` for calling wallet RPC methods
15+
- UPDATED `SessionData` and `UserSession` to only expose a light `UserData` with `profile.stxAddress`
16+
- UPDATED `StacksProvider` to only have a `request` method
17+
- REMOVED `BlockstackProvider`, `StacksProvider`

.changeset/lovely-jobs-fail.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@stacks/connect-ui': major
3+
---
4+
5+
Update UI properties
6+
7+
BREAKING CHANGE:
8+
9+
- RENAMED `persistSelection` to `persistWalletSelect`
10+
- REMOVED `shouldUsePopup` from `@stacks/connect-ui`

.github/workflows/pull_request.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,30 @@ jobs:
6767
- name: Get git commit
6868
id: git-commit
6969
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
70-
- name: print preid
71-
env:
72-
BRANCH: ${{ steps.git-branch.outputs.branch }}
73-
SHA: ${{ steps.git-commit.outputs.sha }}
74-
run: echo $BRANCH.$SHA
70+
- name: Set preid
71+
id: preid
72+
run: |
73+
if [ "${{ steps.git-branch.outputs.branch }}" = "beta" ]; then
74+
echo "preid=beta" >> "$GITHUB_OUTPUT"
75+
else
76+
echo "preid=alpha.${{ steps.git-commit.outputs.sha }}" >> "$GITHUB_OUTPUT"
77+
fi
7578
- name: Setup git
7679
run: |
7780
git config --local user.email "[email protected]"
7881
git config --local user.name "GitHub Action"
7982
- name: Publish to NPM
8083
env:
8184
BRANCH: ${{ steps.git-branch.outputs.branch }}
82-
SHA: ${{ steps.git-commit.outputs.sha }}
83-
run: npx lerna publish prepatch --preid alpha.$SHA --dist-tag $BRANCH --yes --no-push
84-
- name: Get alpha package versions
85-
id: alpha
85+
PREID: ${{ steps.preid.outputs.preid }}
86+
run: npx lerna publish prepatch --preid $PREID --dist-tag $BRANCH --yes --no-push
87+
- name: Get package versions
88+
id: versions
8689
run: |
8790
echo "connect=$(cat packages/connect/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
8891
echo "connectreact=$(cat packages/connect-react/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
8992
echo "connectui=$(cat packages/connect-ui/package.json | jq -r '.version')" >> "$GITHUB_OUTPUT"
9093
- uses: janniks/[email protected]
9194
with:
92-
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`"
95+
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`"
9396
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 80 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,75 @@ This repository includes three packages:
2020
- [`@stacks/connect-react`](./packages/connect-react): A wrapper library for making `@stacks/connect` use in React even easier
2121
- [`@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`)_.
2222

23-
## 🌎 More Information
24-
25-
The [Stacks documentation website](https://docs.stacks.co/build-apps/overview) includes more examples for building apps using Connect.
26-
27-
It also includes guides for various aspects of Stacks application development:
28-
29-
- [Authentication](https://docs.stacks.co/build-apps/references/authentication)
30-
- [Transactions](https://docs.stacks.co/understand-stacks/technical-specs#transactions)
31-
- [Data storage](https://docs.stacks.co/build-apps/references/gaia#understand-data-storage)
32-
33-
## 🐛 Bugs and feature requests
34-
35-
If you encounter a bug or have a feature request, we encourage you to follow the steps below:
36-
37-
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.
38-
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.
39-
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.
40-
41-
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/).
23+
## 🛠️ Wallet Implementation Guide
24+
25+
Wallets implement a "Provider" interface.
26+
The latest spec uses a simple JS Object exposing a `.request(method: string, params?: object)` method.
27+
28+
Pseudo-code:
29+
30+
```ts
31+
window.MyProvider = {
32+
async request(method, params) {
33+
// Somehow communicate with the wallet (e.g. via events)
34+
35+
// Recommendation: Create a JSON RPC 2.0 request object
36+
// https://www.jsonrpc.org/specification
37+
38+
return Promise.resolve({
39+
// Respond with a JSON RPC 2.0 response object
40+
id: crypto.randomUUID(), // required, same as request
41+
jsonrpc: '2.0', // required
42+
43+
// `.result` is required on success
44+
result: {
45+
// object matching specified RPC methods
46+
},
47+
48+
// `.error` is required on error
49+
error: {
50+
// Use existing codes from https://www.jsonrpc.org/specification#error_object
51+
code: number, // required, integer
52+
message: string, // recommended, single sentence
53+
data: object, // optional
54+
},
55+
});
56+
},
57+
isMyWallet: true, // optional, a way of identifying the wallet for developers
58+
};
59+
60+
window.wbip_providers = window.wbip_providers || [];
61+
window.wbip_providers.push({
62+
// `WbipProvider` type
63+
/** The global "path" of the provider (e.g. `"MyProvider"` if registered at `window.MyProvider`) */
64+
id: 'MyProvider',
65+
/** The name of the provider, as displayed to the user */
66+
name: 'My Wallet';
67+
/** 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 */
68+
icon?: 'data:image/png;base64,iVBORw0...';
69+
/** Web URL of the provider */
70+
webUrl?: 'https://mywallet.example.com';
71+
72+
// Addional URLs
73+
chromeWebStoreUrl?: string;
74+
mozillaAddOnsUrl?: string;
75+
googlePlayStoreUrl?: string;
76+
iOSAppStoreUrl?: string;
77+
});
78+
```
79+
80+
### JSON RPC 2.0
81+
82+
Wallets may add their own unstandardized methods.
83+
However, the minimum recommended methods are:
84+
85+
- `getAddresses` [WBIP](https://wbips.netlify.app/request_api/getAddresses)
86+
- `signPsbt` [WBIP](https://wbips.netlify.app/request_api/signPsbt)
87+
- `stx_getAddresses` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)
88+
- `stx_transferStx` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)
89+
- `stx_callContract` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)
90+
- `stx_signMessage` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)
91+
- `stx_signStructuredMessage` [SIP-030](https://github.com/janniks/sips/blob/main/sips/sip-030/sip-030-wallet-interface.md)
4292

4393
## 🎁 Contribute
4494

@@ -59,3 +109,14 @@ Join our community and stay connected with the latest updates and discussions:
59109
- [Join our Discord community chat](https://stacks.chat/) to engage with other users, ask questions, and participate in discussions.
60110
- [Visit hiro.so](https://www.hiro.so/) for updates and subcribing to the mailing list.
61111
- Follow [Hiro on Twitter.](https://twitter.com/hirosystems)
112+
113+
### MIGRATION TODO
114+
115+
#### TODO
116+
117+
- Add `PostConditionModeName` to all options (new and old) — This might have been missing since the v7 release.
118+
- Strip unserializable fields from RawLegacy wrapper just in case.
119+
- Remove exports from LEGACY_XYZ
120+
- Make hex to base64 for psbt
121+
122+
Search for the below and replace with inline return.

0 commit comments

Comments
 (0)