feat: replace postActions/extraMsg with safe_deposit for UTXO deposits#458
feat: replace postActions/extraMsg with safe_deposit for UTXO deposits#458
Conversation
The bridge API now uses view calls instead of on-chain transactions to generate deposit addresses, avoiding NotEnoughBalance errors. Replace postActions/extraMsg with safe_deposit on getUtxoDepositAddress, and use safe_verify_deposit when finalizing deposits with safe_deposit. Matches bridge-sdk-rs#260.
|
There was a problem hiding this comment.
Pull request overview
This PR migrates UTXO deposit flows away from postActions/extraMsg to a safe_deposit message, updating the core API client + bridge interface, and updating the NEAR builder to use safe_verify_deposit (with the required attached deposit) when applicable. It also removes pre-existing non-null assertions in Starknet byte array decoding.
Changes:
- Update Core
BridgeAPI.getUtxoDepositAddress+Bridge.getUtxoDepositAddressoptions to acceptsafeDeposit/ sendsafe_deposit. - Update NEAR builder to call
safe_verify_deposit(and attachDEPOSIT.SAFE_VERIFY_DEPOSIT) whendepositMsg.safe_depositis provided. - Refactor Starknet
decodeByteArrayto avoid non-null assertions and add a missing-offset guard.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/starknet/src/encoding.ts | Removes non-null assertions in decodeByteArray and adds offset guard. |
| packages/near/src/builder.ts | Switches finalization call to safe_verify_deposit + attaches deposit when safe_deposit is present. |
| packages/near/src/types.ts | Adds UtxoSafeDeposit type and DEPOSIT.SAFE_VERIFY_DEPOSIT constant. |
| packages/near/src/index.ts | Re-exports UtxoSafeDeposit. |
| packages/near/tests/utxo.test.ts | Adds coverage for safe-deposit finalization path. |
| packages/core/src/api.ts | Changes UTXO deposit address API to accept safeDeposit and send safe_deposit. |
| packages/core/src/bridge.ts | Updates bridge-level UTXO deposit options/result to align with safe-deposit flow. |
| packages/core/src/index.ts | Re-exports SafeDeposit. |
| packages/core/tests/api.test.ts | Updates API test to use safeDeposit parameter. |
| docs/reference/near.mdx | Documents safe_deposit and safe_verify_deposit behavior for NEAR builder. |
| docs/reference/core.mdx | Updates Core docs to describe safeDeposit and removes postActions/extraMsg references. |
Comments suppressed due to low confidence (1)
packages/core/tests/api.test.ts:272
- The new
safe_depositbehavior isn’t fully exercised: the MSW handler always returns a response regardless of request body, so this test would still pass even if the client failed to sendsafe_deposit(or sent the wrong key). Consider asserting the POST body includessafe_deposit: { msg: ... }(and notsafeDeposit) in this test/handler.
it("should handle safe_deposit parameter", async () => {
const response = await api.getUtxoDepositAddress("btc", "recipient.near", {
msg: "safe deposit message",
})
expect(response).toEqual({
address: "tb1qssh0ejglq0v53pwrsxlhxpxw29gfu6c4ls9eyy",
})
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const connector = this.getUtxoConnectorAddress(params.chain) | ||
|
|
||
| // Build deposit_msg for the contract (convert bigint amounts to strings) | ||
| const isSafeDeposit = params.depositMsg.safe_deposit != null |
There was a problem hiding this comment.
I think it is better to fully remove the not-safe flow from the bridge SDK js.
I even prefer to fully remove the legacy code in contract, but unfortunately we can't do that because the Satoshi protocol relay on it.
Summary
postActions/extraMsgwithsafe_depositongetUtxoDepositAddressacross core API client and bridge interfacesafe_verify_deposit(with 1.2 mNEAR deposit) instead ofverify_depositwhensafe_depositis presentnoNonNullAssertionlint warnings in starknet encodingMatches bridge-sdk-rs#260.
Test plan
bun run buildpassesbun run lintpasses (0 warnings)bun run test packages/— 263 tests pass