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

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 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
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`
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",

// Jest -> Vitest: Run
"jestrunner.jestCommand": "npx vitest run",

// Jest -> Vitest: Debug (Hack)
"jestrunner.jestPath": "node_modules/.bin/vitest",
"jestrunner.runOptions": ["--"],
"jestrunner.debugOptions": {
"args": ["run"]
}
}
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