swig-developer-sdk 0.8.0__tar.gz → 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/PKG-INFO +171 -19
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/README.md +169 -18
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/pyproject.toml +2 -1
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/scripts/local_transaction_e2e.py +238 -5
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/__init__.py +72 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/client.py +2 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/common.py +21 -0
- swig_developer_sdk-0.9.0/src/swig_developer_sdk/participant_sets.py +100 -0
- swig_developer_sdk-0.9.0/src/swig_developer_sdk/participant_signers.py +254 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/proxy.py +19 -1
- swig_developer_sdk-0.9.0/src/swig_developer_sdk/signers.py +90 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/transactions.py +313 -2
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/wallets.py +322 -0
- swig_developer_sdk-0.9.0/src/swig_developer_sdk/x402.py +300 -0
- swig_developer_sdk-0.9.0/tests/test_participant_sets.py +495 -0
- swig_developer_sdk-0.9.0/tests/test_participant_signers.py +147 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/tests/test_proxy.py +65 -0
- swig_developer_sdk-0.9.0/tests/test_signers_boundary.py +54 -0
- swig_developer_sdk-0.9.0/tests/test_x402.py +194 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/uv.lock +178 -1
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/.gitignore +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/LICENSE.txt +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/core.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/evm.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/one_business.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/passkeys.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/paymaster.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/ramp.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/src/swig_developer_sdk/signing.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/tests/test_client.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/tests/test_helpers.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/tests/test_resource_clients.py +0 -0
- {swig_developer_sdk-0.8.0 → swig_developer_sdk-0.9.0}/tests/test_signing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: swig-developer-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: Python SDK for preparing and locally signing Swig wallet transactions
|
|
5
5
|
Project-URL: Repository, https://github.com/anagrambuild/swig-developer-sdk
|
|
6
6
|
Author: Anagram
|
|
@@ -22,16 +22,17 @@ Requires-Python: >=3.10
|
|
|
22
22
|
Requires-Dist: base58<3,>=2.1
|
|
23
23
|
Requires-Dist: httpx<1,>=0.28
|
|
24
24
|
Requires-Dist: solders<0.29,>=0.28
|
|
25
|
+
Requires-Dist: x402==2.18.0
|
|
25
26
|
Description-Content-Type: text/markdown
|
|
26
27
|
|
|
27
28
|
# swig-developer-sdk
|
|
28
29
|
|
|
29
|
-
Python SDK for preparing Swig wallet operations on a server
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
material is sent to the API.
|
|
30
|
+
Python SDK for preparing Swig wallet operations on a server, with a separate
|
|
31
|
+
`swig_developer_sdk.signers` module for application-owned signing. The signer
|
|
32
|
+
module inserts signatures with `solders` and makes no hosted API requests. No
|
|
33
|
+
signing material is sent to the API.
|
|
33
34
|
|
|
34
|
-
- Version: `0.
|
|
35
|
+
- Version: `0.9.0`
|
|
35
36
|
- Source: <https://github.com/anagrambuild/swig-developer-sdk>
|
|
36
37
|
- Default API base URL: `https://api.onswig.com`
|
|
37
38
|
|
|
@@ -126,6 +127,102 @@ wallet = swig.wallets.use(
|
|
|
126
127
|
`swig.wallets.from_idp_session(session)` builds the same handle from an IdP
|
|
127
128
|
session.
|
|
128
129
|
|
|
130
|
+
### Configure and use a ParticipantSet
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from swig_developer_sdk import ProgramAction, SolLimitAction
|
|
134
|
+
|
|
135
|
+
created_set = await swig.participant_sets.create(
|
|
136
|
+
swig_config_address=swig_config_address,
|
|
137
|
+
fee_payer=fee_payer,
|
|
138
|
+
threshold=2,
|
|
139
|
+
members=(
|
|
140
|
+
{"ed25519": {"publicKey": recovery_public_key}},
|
|
141
|
+
{"secp256r1": {"publicKey": client_public_key}},
|
|
142
|
+
{"secp256k1": {"publicKey": server_public_key}},
|
|
143
|
+
),
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
wallet = swig.wallets.use(
|
|
147
|
+
swig_config_address,
|
|
148
|
+
requester_authority=requester_authority,
|
|
149
|
+
)
|
|
150
|
+
add_role = await wallet.roles.add(
|
|
151
|
+
fee_payer=fee_payer,
|
|
152
|
+
authority={
|
|
153
|
+
"participantSet": {"address": created_set.participant_set_address}
|
|
154
|
+
},
|
|
155
|
+
actions=(
|
|
156
|
+
SolLimitAction(amount=1_000_000),
|
|
157
|
+
ProgramAction(program_id=program_id),
|
|
158
|
+
),
|
|
159
|
+
)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
After submitting the setup transactions, prepare an action with a ParticipantSet
|
|
163
|
+
requester and compile detached approvals:
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
participant_wallet = swig.wallets.use(
|
|
167
|
+
swig_config_address,
|
|
168
|
+
requester_authority={
|
|
169
|
+
"participantSet": {"address": created_set.participant_set_address}
|
|
170
|
+
},
|
|
171
|
+
)
|
|
172
|
+
prepared = await participant_wallet.transfer.sol(
|
|
173
|
+
fee_payer=fee_payer,
|
|
174
|
+
destination=destination,
|
|
175
|
+
amount=1_000_000,
|
|
176
|
+
)
|
|
177
|
+
compiled = await swig.transactions.compile_participant_set_approvals(
|
|
178
|
+
prepared_transaction=prepared,
|
|
179
|
+
approvals=approvals,
|
|
180
|
+
)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The plan uses one shared nonce, and each member approval signs its returned
|
|
184
|
+
challenge. Compilation returns `compiled.transaction` plus
|
|
185
|
+
`compiled.authorization_expiration_slot`; it does not sponsor, submit, or
|
|
186
|
+
broadcast the result.
|
|
187
|
+
|
|
188
|
+
### Prepare an x402 payment
|
|
189
|
+
|
|
190
|
+
Pass the resource server's `402 Payment Required` response directly to the
|
|
191
|
+
wallet. When `accepted_index` is omitted, Swig selects the first eligible exact
|
|
192
|
+
Solana requirement and returns its original array index.
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
import httpx
|
|
196
|
+
|
|
197
|
+
from swig_developer_sdk import create_x402_payment
|
|
198
|
+
from swig_developer_sdk.signers import sign_prepared_transaction
|
|
199
|
+
|
|
200
|
+
async with httpx.AsyncClient() as http:
|
|
201
|
+
challenge = await http.get(resource_url)
|
|
202
|
+
prepared = await wallet.x402.prepare_from_response(challenge)
|
|
203
|
+
signed = await sign_prepared_transaction(
|
|
204
|
+
prepared.prepared_transaction,
|
|
205
|
+
sign_transaction=sign_transaction,
|
|
206
|
+
)
|
|
207
|
+
payment = create_x402_payment(prepared, signed)
|
|
208
|
+
response = await http.get(
|
|
209
|
+
resource_url,
|
|
210
|
+
headers=payment.payment_signature_headers,
|
|
211
|
+
)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
To choose a specific offer from the original `accepts` array:
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
prepared = await wallet.x402.prepare_from_response(
|
|
218
|
+
challenge,
|
|
219
|
+
accepted_index=accepted_index,
|
|
220
|
+
)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Use `sign_prepared_transaction` for Ed25519 authorities and
|
|
224
|
+
`sign_prepared_swig_transaction` for Secp256r1/passkey authorities.
|
|
225
|
+
|
|
129
226
|
### Prepare transfers and swaps
|
|
130
227
|
|
|
131
228
|
```python
|
|
@@ -307,7 +404,8 @@ Offramp adds an on-chain authorization step: the user's wallet must sign the
|
|
|
307
404
|
transfer to the provider before the session can settle.
|
|
308
405
|
|
|
309
406
|
```python
|
|
310
|
-
from swig_developer_sdk import QuoteRampArgs
|
|
407
|
+
from swig_developer_sdk import QuoteRampArgs
|
|
408
|
+
from swig_developer_sdk.signers import sign_prepared_swig_transaction
|
|
311
409
|
|
|
312
410
|
options = await swig.ramp.offramp.get_options(
|
|
313
411
|
organization_meld_configuration_id=configuration_id,
|
|
@@ -369,8 +467,57 @@ The generic signer helper works with an application-owned Ed25519 signer. The
|
|
|
369
467
|
Swig signer helper patches secp256r1 or secp256k1 signatures into both legacy
|
|
370
468
|
and versioned Solana transactions.
|
|
371
469
|
|
|
470
|
+
ParticipantSet signers operate on one bound member request and never call the
|
|
471
|
+
hosted API:
|
|
472
|
+
|
|
473
|
+
```python
|
|
474
|
+
from swig_developer_sdk.signers import (
|
|
475
|
+
create_participant_ed25519_signer,
|
|
476
|
+
create_participant_passkey_signer,
|
|
477
|
+
create_participant_personal_sign_signer,
|
|
478
|
+
sign_participant_set_approval,
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
recovery_signer = create_participant_ed25519_signer(
|
|
482
|
+
public_key=recovery_public_key,
|
|
483
|
+
sign_message=sign_ed25519,
|
|
484
|
+
)
|
|
485
|
+
recovery_approval = await sign_participant_set_approval(
|
|
486
|
+
prepared.participant_set_approval_plan.members[0],
|
|
487
|
+
recovery_signer,
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
passkey_signer = create_participant_passkey_signer(
|
|
491
|
+
public_key=client_public_key,
|
|
492
|
+
get_assertion=get_webauthn_assertion,
|
|
493
|
+
)
|
|
494
|
+
client_approval = await sign_participant_set_approval(
|
|
495
|
+
prepared.participant_set_approval_plan.members[1],
|
|
496
|
+
passkey_signer,
|
|
497
|
+
)
|
|
498
|
+
|
|
499
|
+
server_signer = create_participant_personal_sign_signer(
|
|
500
|
+
public_key=server_public_key,
|
|
501
|
+
# personal_sign applies EIP-191 to this exact 64-character lowercase
|
|
502
|
+
# ASCII hex challenge.
|
|
503
|
+
sign_message=personal_sign,
|
|
504
|
+
)
|
|
505
|
+
server_approval = await sign_participant_set_approval(
|
|
506
|
+
prepared.participant_set_approval_plan.members[2],
|
|
507
|
+
server_signer,
|
|
508
|
+
)
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
The Ed25519 callback receives the decoded 32-byte challenge. The shared
|
|
512
|
+
ParticipantSet nonce is already committed by every challenge and is not copied
|
|
513
|
+
into individual approvals. The passkey adapter returns exact assertion bytes
|
|
514
|
+
and converts DER to a raw low-S P-256 signature; compilation also defensively
|
|
515
|
+
normalizes externally constructed high-S P-256 approvals. The personal-sign
|
|
516
|
+
adapter validates compact k1 signatures, normalizes low-S, and adjusts the
|
|
517
|
+
recovery byte. None of these helpers calls the hosted API.
|
|
518
|
+
|
|
372
519
|
```python
|
|
373
|
-
from swig_developer_sdk import (
|
|
520
|
+
from swig_developer_sdk.signers import (
|
|
374
521
|
sign_prepared_swig_transaction,
|
|
375
522
|
sign_prepared_transaction,
|
|
376
523
|
)
|
|
@@ -394,7 +541,7 @@ a browser, hardware, wallet, or remote signer without changing the preparation
|
|
|
394
541
|
API:
|
|
395
542
|
|
|
396
543
|
```python
|
|
397
|
-
from swig_developer_sdk import (
|
|
544
|
+
from swig_developer_sdk.signers import (
|
|
398
545
|
create_secp256k1_evm_signing_fn,
|
|
399
546
|
create_secp256r1_passkey_signing_fn,
|
|
400
547
|
)
|
|
@@ -486,17 +633,17 @@ response = await swig_handler.handle(
|
|
|
486
633
|
# return response.body with response.status
|
|
487
634
|
```
|
|
488
635
|
|
|
489
|
-
The handler covers
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
offramp routes.
|
|
636
|
+
The handler covers wallet creation, grouped preparation, SOL and SPL transfers,
|
|
637
|
+
Jupiter swaps, wallet USD balance, token balances, token transactions, roles,
|
|
638
|
+
x402 payment preparation, paymaster balance, and the onramp and offramp routes.
|
|
493
639
|
|
|
494
640
|
`SwigProxyConfig` accepts `api_key`, `transaction_api_url`, `network`,
|
|
495
641
|
`fee_payer` (a value or a callable resolved per request),
|
|
496
642
|
`resolve_requester_authority`, and an optional `httpx` transport. It falls back
|
|
497
643
|
to `SWIG_DEVELOPER_API_KEY` / `SWIG_API_KEY`, `SWIG_TRANSACTION_API_URL`, and
|
|
498
|
-
`SWIG_FEE_PAYER` when those fields are unset. A fee payer is required for
|
|
499
|
-
preparation
|
|
644
|
+
`SWIG_FEE_PAYER` when those fields are unset. A fee payer is required for
|
|
645
|
+
preparation routes other than x402; x402 obtains its sponsor fee payer from the
|
|
646
|
+
selected payment requirement.
|
|
500
647
|
|
|
501
648
|
## Errors
|
|
502
649
|
|
|
@@ -520,14 +667,19 @@ Keep API keys, signed transactions, and ramp launch URLs out of logs.
|
|
|
520
667
|
`scripts/local_transaction_e2e.py` exercises wallet creation, real P-256
|
|
521
668
|
signing, direct and grouped SOL transfers, an SPL-token transfer, the Python
|
|
522
669
|
proxy, the live paymaster balance endpoint, and a sponsored transfer where the
|
|
523
|
-
user pays no network fee.
|
|
524
|
-
|
|
525
|
-
|
|
670
|
+
user pays no network fee. It also creates a two-member ParticipantSet, adds it
|
|
671
|
+
as a general role, compiles detached Ed25519 approvals, executes the transfer,
|
|
672
|
+
and proves that another approval plan using the consumed shared nonce is
|
|
673
|
+
rejected. Every transaction is submitted to Surfpool and verified on-chain;
|
|
674
|
+
the paymaster flow also retries with the same idempotency key and verifies that
|
|
675
|
+
no balance change repeats.
|
|
526
676
|
|
|
527
677
|
It requires a locally running backend stack, and defaults to
|
|
528
678
|
`http://localhost:8080` for the Developer API and `http://localhost:8899` for
|
|
529
679
|
Surfpool. Override with `SWIG_TRANSACTION_API_URL`, `SOLANA_RPC_URL`, or
|
|
530
|
-
`SWIG_DATABASE_URL`.
|
|
680
|
+
`SWIG_DATABASE_URL`. Set `SWIG_E2E_SKIP_PAYMASTER=1` when validating only the
|
|
681
|
+
transaction-service and Surfpool path; the receipt explicitly records that the
|
|
682
|
+
paymaster phase was skipped.
|
|
531
683
|
|
|
532
684
|
Jupiter is not covered by this script, since it needs a mainnet-backed
|
|
533
685
|
Surfpool.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# swig-developer-sdk
|
|
2
2
|
|
|
3
|
-
Python SDK for preparing Swig wallet operations on a server
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
material is sent to the API.
|
|
3
|
+
Python SDK for preparing Swig wallet operations on a server, with a separate
|
|
4
|
+
`swig_developer_sdk.signers` module for application-owned signing. The signer
|
|
5
|
+
module inserts signatures with `solders` and makes no hosted API requests. No
|
|
6
|
+
signing material is sent to the API.
|
|
7
7
|
|
|
8
|
-
- Version: `0.
|
|
8
|
+
- Version: `0.9.0`
|
|
9
9
|
- Source: <https://github.com/anagrambuild/swig-developer-sdk>
|
|
10
10
|
- Default API base URL: `https://api.onswig.com`
|
|
11
11
|
|
|
@@ -100,6 +100,102 @@ wallet = swig.wallets.use(
|
|
|
100
100
|
`swig.wallets.from_idp_session(session)` builds the same handle from an IdP
|
|
101
101
|
session.
|
|
102
102
|
|
|
103
|
+
### Configure and use a ParticipantSet
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from swig_developer_sdk import ProgramAction, SolLimitAction
|
|
107
|
+
|
|
108
|
+
created_set = await swig.participant_sets.create(
|
|
109
|
+
swig_config_address=swig_config_address,
|
|
110
|
+
fee_payer=fee_payer,
|
|
111
|
+
threshold=2,
|
|
112
|
+
members=(
|
|
113
|
+
{"ed25519": {"publicKey": recovery_public_key}},
|
|
114
|
+
{"secp256r1": {"publicKey": client_public_key}},
|
|
115
|
+
{"secp256k1": {"publicKey": server_public_key}},
|
|
116
|
+
),
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
wallet = swig.wallets.use(
|
|
120
|
+
swig_config_address,
|
|
121
|
+
requester_authority=requester_authority,
|
|
122
|
+
)
|
|
123
|
+
add_role = await wallet.roles.add(
|
|
124
|
+
fee_payer=fee_payer,
|
|
125
|
+
authority={
|
|
126
|
+
"participantSet": {"address": created_set.participant_set_address}
|
|
127
|
+
},
|
|
128
|
+
actions=(
|
|
129
|
+
SolLimitAction(amount=1_000_000),
|
|
130
|
+
ProgramAction(program_id=program_id),
|
|
131
|
+
),
|
|
132
|
+
)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
After submitting the setup transactions, prepare an action with a ParticipantSet
|
|
136
|
+
requester and compile detached approvals:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
participant_wallet = swig.wallets.use(
|
|
140
|
+
swig_config_address,
|
|
141
|
+
requester_authority={
|
|
142
|
+
"participantSet": {"address": created_set.participant_set_address}
|
|
143
|
+
},
|
|
144
|
+
)
|
|
145
|
+
prepared = await participant_wallet.transfer.sol(
|
|
146
|
+
fee_payer=fee_payer,
|
|
147
|
+
destination=destination,
|
|
148
|
+
amount=1_000_000,
|
|
149
|
+
)
|
|
150
|
+
compiled = await swig.transactions.compile_participant_set_approvals(
|
|
151
|
+
prepared_transaction=prepared,
|
|
152
|
+
approvals=approvals,
|
|
153
|
+
)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The plan uses one shared nonce, and each member approval signs its returned
|
|
157
|
+
challenge. Compilation returns `compiled.transaction` plus
|
|
158
|
+
`compiled.authorization_expiration_slot`; it does not sponsor, submit, or
|
|
159
|
+
broadcast the result.
|
|
160
|
+
|
|
161
|
+
### Prepare an x402 payment
|
|
162
|
+
|
|
163
|
+
Pass the resource server's `402 Payment Required` response directly to the
|
|
164
|
+
wallet. When `accepted_index` is omitted, Swig selects the first eligible exact
|
|
165
|
+
Solana requirement and returns its original array index.
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
import httpx
|
|
169
|
+
|
|
170
|
+
from swig_developer_sdk import create_x402_payment
|
|
171
|
+
from swig_developer_sdk.signers import sign_prepared_transaction
|
|
172
|
+
|
|
173
|
+
async with httpx.AsyncClient() as http:
|
|
174
|
+
challenge = await http.get(resource_url)
|
|
175
|
+
prepared = await wallet.x402.prepare_from_response(challenge)
|
|
176
|
+
signed = await sign_prepared_transaction(
|
|
177
|
+
prepared.prepared_transaction,
|
|
178
|
+
sign_transaction=sign_transaction,
|
|
179
|
+
)
|
|
180
|
+
payment = create_x402_payment(prepared, signed)
|
|
181
|
+
response = await http.get(
|
|
182
|
+
resource_url,
|
|
183
|
+
headers=payment.payment_signature_headers,
|
|
184
|
+
)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
To choose a specific offer from the original `accepts` array:
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
prepared = await wallet.x402.prepare_from_response(
|
|
191
|
+
challenge,
|
|
192
|
+
accepted_index=accepted_index,
|
|
193
|
+
)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Use `sign_prepared_transaction` for Ed25519 authorities and
|
|
197
|
+
`sign_prepared_swig_transaction` for Secp256r1/passkey authorities.
|
|
198
|
+
|
|
103
199
|
### Prepare transfers and swaps
|
|
104
200
|
|
|
105
201
|
```python
|
|
@@ -281,7 +377,8 @@ Offramp adds an on-chain authorization step: the user's wallet must sign the
|
|
|
281
377
|
transfer to the provider before the session can settle.
|
|
282
378
|
|
|
283
379
|
```python
|
|
284
|
-
from swig_developer_sdk import QuoteRampArgs
|
|
380
|
+
from swig_developer_sdk import QuoteRampArgs
|
|
381
|
+
from swig_developer_sdk.signers import sign_prepared_swig_transaction
|
|
285
382
|
|
|
286
383
|
options = await swig.ramp.offramp.get_options(
|
|
287
384
|
organization_meld_configuration_id=configuration_id,
|
|
@@ -343,8 +440,57 @@ The generic signer helper works with an application-owned Ed25519 signer. The
|
|
|
343
440
|
Swig signer helper patches secp256r1 or secp256k1 signatures into both legacy
|
|
344
441
|
and versioned Solana transactions.
|
|
345
442
|
|
|
443
|
+
ParticipantSet signers operate on one bound member request and never call the
|
|
444
|
+
hosted API:
|
|
445
|
+
|
|
446
|
+
```python
|
|
447
|
+
from swig_developer_sdk.signers import (
|
|
448
|
+
create_participant_ed25519_signer,
|
|
449
|
+
create_participant_passkey_signer,
|
|
450
|
+
create_participant_personal_sign_signer,
|
|
451
|
+
sign_participant_set_approval,
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
recovery_signer = create_participant_ed25519_signer(
|
|
455
|
+
public_key=recovery_public_key,
|
|
456
|
+
sign_message=sign_ed25519,
|
|
457
|
+
)
|
|
458
|
+
recovery_approval = await sign_participant_set_approval(
|
|
459
|
+
prepared.participant_set_approval_plan.members[0],
|
|
460
|
+
recovery_signer,
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
passkey_signer = create_participant_passkey_signer(
|
|
464
|
+
public_key=client_public_key,
|
|
465
|
+
get_assertion=get_webauthn_assertion,
|
|
466
|
+
)
|
|
467
|
+
client_approval = await sign_participant_set_approval(
|
|
468
|
+
prepared.participant_set_approval_plan.members[1],
|
|
469
|
+
passkey_signer,
|
|
470
|
+
)
|
|
471
|
+
|
|
472
|
+
server_signer = create_participant_personal_sign_signer(
|
|
473
|
+
public_key=server_public_key,
|
|
474
|
+
# personal_sign applies EIP-191 to this exact 64-character lowercase
|
|
475
|
+
# ASCII hex challenge.
|
|
476
|
+
sign_message=personal_sign,
|
|
477
|
+
)
|
|
478
|
+
server_approval = await sign_participant_set_approval(
|
|
479
|
+
prepared.participant_set_approval_plan.members[2],
|
|
480
|
+
server_signer,
|
|
481
|
+
)
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
The Ed25519 callback receives the decoded 32-byte challenge. The shared
|
|
485
|
+
ParticipantSet nonce is already committed by every challenge and is not copied
|
|
486
|
+
into individual approvals. The passkey adapter returns exact assertion bytes
|
|
487
|
+
and converts DER to a raw low-S P-256 signature; compilation also defensively
|
|
488
|
+
normalizes externally constructed high-S P-256 approvals. The personal-sign
|
|
489
|
+
adapter validates compact k1 signatures, normalizes low-S, and adjusts the
|
|
490
|
+
recovery byte. None of these helpers calls the hosted API.
|
|
491
|
+
|
|
346
492
|
```python
|
|
347
|
-
from swig_developer_sdk import (
|
|
493
|
+
from swig_developer_sdk.signers import (
|
|
348
494
|
sign_prepared_swig_transaction,
|
|
349
495
|
sign_prepared_transaction,
|
|
350
496
|
)
|
|
@@ -368,7 +514,7 @@ a browser, hardware, wallet, or remote signer without changing the preparation
|
|
|
368
514
|
API:
|
|
369
515
|
|
|
370
516
|
```python
|
|
371
|
-
from swig_developer_sdk import (
|
|
517
|
+
from swig_developer_sdk.signers import (
|
|
372
518
|
create_secp256k1_evm_signing_fn,
|
|
373
519
|
create_secp256r1_passkey_signing_fn,
|
|
374
520
|
)
|
|
@@ -460,17 +606,17 @@ response = await swig_handler.handle(
|
|
|
460
606
|
# return response.body with response.status
|
|
461
607
|
```
|
|
462
608
|
|
|
463
|
-
The handler covers
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
offramp routes.
|
|
609
|
+
The handler covers wallet creation, grouped preparation, SOL and SPL transfers,
|
|
610
|
+
Jupiter swaps, wallet USD balance, token balances, token transactions, roles,
|
|
611
|
+
x402 payment preparation, paymaster balance, and the onramp and offramp routes.
|
|
467
612
|
|
|
468
613
|
`SwigProxyConfig` accepts `api_key`, `transaction_api_url`, `network`,
|
|
469
614
|
`fee_payer` (a value or a callable resolved per request),
|
|
470
615
|
`resolve_requester_authority`, and an optional `httpx` transport. It falls back
|
|
471
616
|
to `SWIG_DEVELOPER_API_KEY` / `SWIG_API_KEY`, `SWIG_TRANSACTION_API_URL`, and
|
|
472
|
-
`SWIG_FEE_PAYER` when those fields are unset. A fee payer is required for
|
|
473
|
-
preparation
|
|
617
|
+
`SWIG_FEE_PAYER` when those fields are unset. A fee payer is required for
|
|
618
|
+
preparation routes other than x402; x402 obtains its sponsor fee payer from the
|
|
619
|
+
selected payment requirement.
|
|
474
620
|
|
|
475
621
|
## Errors
|
|
476
622
|
|
|
@@ -494,14 +640,19 @@ Keep API keys, signed transactions, and ramp launch URLs out of logs.
|
|
|
494
640
|
`scripts/local_transaction_e2e.py` exercises wallet creation, real P-256
|
|
495
641
|
signing, direct and grouped SOL transfers, an SPL-token transfer, the Python
|
|
496
642
|
proxy, the live paymaster balance endpoint, and a sponsored transfer where the
|
|
497
|
-
user pays no network fee.
|
|
498
|
-
|
|
499
|
-
|
|
643
|
+
user pays no network fee. It also creates a two-member ParticipantSet, adds it
|
|
644
|
+
as a general role, compiles detached Ed25519 approvals, executes the transfer,
|
|
645
|
+
and proves that another approval plan using the consumed shared nonce is
|
|
646
|
+
rejected. Every transaction is submitted to Surfpool and verified on-chain;
|
|
647
|
+
the paymaster flow also retries with the same idempotency key and verifies that
|
|
648
|
+
no balance change repeats.
|
|
500
649
|
|
|
501
650
|
It requires a locally running backend stack, and defaults to
|
|
502
651
|
`http://localhost:8080` for the Developer API and `http://localhost:8899` for
|
|
503
652
|
Surfpool. Override with `SWIG_TRANSACTION_API_URL`, `SOLANA_RPC_URL`, or
|
|
504
|
-
`SWIG_DATABASE_URL`.
|
|
653
|
+
`SWIG_DATABASE_URL`. Set `SWIG_E2E_SKIP_PAYMASTER=1` when validating only the
|
|
654
|
+
transaction-service and Surfpool path; the receipt explicitly records that the
|
|
655
|
+
paymaster phase was skipped.
|
|
505
656
|
|
|
506
657
|
Jupiter is not covered by this script, since it needs a mainnet-backed
|
|
507
658
|
Surfpool.
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "swig-developer-sdk"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.9.0"
|
|
8
8
|
description = "Python SDK for preparing and locally signing Swig wallet transactions"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -14,6 +14,7 @@ dependencies = [
|
|
|
14
14
|
"base58>=2.1,<3",
|
|
15
15
|
"httpx>=0.28,<1",
|
|
16
16
|
"solders>=0.28,<0.29",
|
|
17
|
+
"x402==2.18.0",
|
|
17
18
|
]
|
|
18
19
|
|
|
19
20
|
[project.urls]
|