-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add Stellar signatures support #558
Changes from all commits
d79a558
bb45e0f
460f648
75bd822
75ce57b
41a6df4
cc21919
bf0eb00
2deb951
39603d0
1000b20
a17722b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { authIdentity } from "@defuse-protocol/internal-utils" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainCritical: authIdentity not exported from external package. The static analysis indicates that Please verify the external package exports the 🏁 Script executed: #!/usr/bin/env bash
set -e
# Download the package tarball
PKG=$(npm pack @defuse-protocol/internal-utils)
echo "Packed as $PKG"
# List all JavaScript and TypeScript declaration files in the tarball
FILES=$(tar -tzf "$PKG" | grep -E '\.js$|\.d\.ts$')
echo "Relevant files:"
echo "$FILES"
# Search each file for the authIdentity export
echo "Searching for 'authIdentity' occurrences..."
for f in $FILES; do
echo "=== $f ==="
tar -xzOf "$PKG" "$f" | grep -H "authIdentity" || true
doneLength of output: 1674 Critical: The package’s declaration file ( • File: src/core/messages.test.ts import { authIdentity } from "@defuse-protocol/internal-utils"• Evidence: Please either:
🧰 Tools🪛 GitHub Check: test / test[failure] 1-1: 🤖 Prompt for AI Agents |
||
| import { describe, expect, it } from "vitest" | ||
| import { authHandleToIntentsUserId } from "../utils/authIdentity" | ||
| import { | ||
| createEmptyIntentMessage, | ||
| createSwapIntentMessage, | ||
|
|
@@ -8,7 +8,7 @@ | |
| } from "./messages" | ||
|
|
||
| const TEST_TIMESTAMP = 1704110400000 // 2024-01-01T12:00:00.000Z | ||
| const TEST_USER = authHandleToIntentsUserId("user.near", "near") | ||
| const TEST_USER = authIdentity.authHandleToIntentsUserId("user.near", "near") | ||
|
|
||
| describe("createSwapIntentMessage()", () => { | ||
| it("creates a valid swap intent message", () => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,8 @@ | ||
| import type { IntentsUserId } from "../types/intentsUserId" | ||
| import type { WalletMessage } from "../types/walletMessage" | ||
| import { | ||
| type WithdrawParams, | ||
| makeEmptyMessage, | ||
| makeInnerSwapAndWithdrawMessage, | ||
| makeInnerSwapMessage, | ||
| makeInnerTransferMessage, | ||
| makeSwapMessage, | ||
| } from "../utils/messageFactory" | ||
| messageFactory, | ||
| type walletMessage, | ||
| } from "@defuse-protocol/internal-utils" | ||
|
Comment on lines
1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: External package missing required exports. The import changes are structurally correct, but static analysis indicates that This appears to be a dependency issue where the changes in this repository depend on the related PR mentioned in the objectives: defuse-protocol/sdk-monorepo#60 Ensure that the dependency PR is merged and the package is updated before merging these changes. 🧰 Tools🪛 GitHub Check: test / test[failure] 3-3: [failure] 2-2: 🤖 Prompt for AI Agents |
||
| import type { IntentsUserId } from "../types/intentsUserId" | ||
| import type { SignerCredentials } from "./formatters" | ||
| import { formatUserIdentity } from "./formatters" | ||
|
|
||
|
|
@@ -37,7 +32,7 @@ | |
| memo?: string | ||
| } | ||
|
|
||
| export type WithdrawIntentMessageConfig = WithdrawParams | ||
| export type WithdrawIntentMessageConfig = messageFactory.WithdrawParams | ||
|
|
||
| function resolveSignerId( | ||
| signerId: IntentsUserId | SignerCredentials | ||
|
|
@@ -54,16 +49,16 @@ | |
| export function createSwapIntentMessage( | ||
| swapConfig: [string, bigint][], | ||
| options: IntentMessageConfig | ||
| ): WalletMessage { | ||
| const innerMessage = makeInnerSwapMessage({ | ||
| ): walletMessage.WalletMessage { | ||
| const innerMessage = messageFactory.makeInnerSwapMessage({ | ||
| tokenDeltas: swapConfig, | ||
| signerId: resolveSignerId(options.signerId), | ||
| deadlineTimestamp: options.deadlineTimestamp ?? minutesFromNow(5), | ||
| referral: options.referral, | ||
| memo: options.memo, | ||
| }) | ||
|
|
||
| return makeSwapMessage({ | ||
| return messageFactory.makeSwapMessage({ | ||
| innerMessage, | ||
| nonce: options.nonce, | ||
| }) | ||
|
|
@@ -78,16 +73,16 @@ | |
| export function createWithdrawIntentMessage( | ||
| withdrawConfig: WithdrawIntentMessageConfig, | ||
| options: IntentMessageConfig | ||
| ): WalletMessage { | ||
| const innerMessage = makeInnerSwapAndWithdrawMessage({ | ||
| ): walletMessage.WalletMessage { | ||
| const innerMessage = messageFactory.makeInnerSwapAndWithdrawMessage({ | ||
| tokenDeltas: [], | ||
| storageTokenDeltas: [], | ||
| withdrawParams: withdrawConfig, | ||
| signerId: resolveSignerId(options.signerId), | ||
| deadlineTimestamp: options.deadlineTimestamp ?? minutesFromNow(5), | ||
| }) | ||
|
|
||
| return makeSwapMessage({ | ||
| return messageFactory.makeSwapMessage({ | ||
| innerMessage, | ||
| nonce: options.nonce, | ||
| }) | ||
|
|
@@ -100,8 +95,8 @@ | |
| */ | ||
| export function createEmptyIntentMessage( | ||
| options: IntentMessageConfig | ||
| ): WalletMessage { | ||
| return makeEmptyMessage({ | ||
| ): walletMessage.WalletMessage { | ||
| return messageFactory.makeEmptyMessage({ | ||
| signerId: resolveSignerId(options.signerId), | ||
| deadlineTimestamp: options.deadlineTimestamp ?? minutesFromNow(5), | ||
| nonce: options.nonce, | ||
|
|
@@ -121,16 +116,16 @@ | |
| export function createTransferMessage( | ||
| tokenDeltas: [string, bigint][], | ||
| options: IntentMessageConfig & { receiverId: string } | ||
| ): WalletMessage { | ||
| const innerMessage = makeInnerTransferMessage({ | ||
| ): walletMessage.WalletMessage { | ||
| const innerMessage = messageFactory.makeInnerTransferMessage({ | ||
| tokenDeltas, | ||
| signerId: resolveSignerId(options.signerId), | ||
| deadlineTimestamp: options.deadlineTimestamp ?? minutesFromNow(5), | ||
| receiverId: options.receiverId, | ||
| memo: options.memo, | ||
| }) | ||
|
|
||
| return makeSwapMessage({ | ||
| return messageFactory.makeSwapMessage({ | ||
| innerMessage, | ||
| nonce: options.nonce, | ||
| }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import type { walletMessage } from "@defuse-protocol/internal-utils" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainCritical: Module export mismatch causing compilation failure. The static analysis reports that Please verify the export structure of the Since this PR depends on defuse-protocol/sdk-monorepo#60, ensure that dependency is merged and the package version is updated accordingly. Also applies to: 53-55 🏁 Script executed: #!/bin/bash
# Description: Check the exported members of the external package
# Expected: Should show walletMessage export
# Check if the package is installed and its exports
cat package.json | jq '.dependencies["@defuse-protocol/internal-utils"]'
# If package is available, check its TypeScript definitions
fd -e d.ts -x cat {} \; --search-path node_modules/@defuse-protocol/internal-utils | head -50Length of output: 313 🏁 Script executed: #!/bin/bash
# Fetch package manifest fields for types and main entry
npm view @defuse-protocol/internal-utils@0.1.2 types main --json
# Attempt to download the TypeScript definitions from unpkg, if a types field exists
types=$(npm view @defuse-protocol/internal-utils@0.1.2 types)
if [ -n "$types" ]; then
echo "==> Downloading definitions for $types from unpkg"
curl -s "https://unpkg.com/@defuse-protocol/internal-utils@0.1.2/$types" | head -200
else
echo "No 'types' entry in package manifest; trying to inspect index.d.ts"
curl -s "https://unpkg.com/@defuse-protocol/internal-utils@0.1.2/index.d.ts" | head -200
fiLength of output: 6684 Critical: The TypeScript definitions for version 0.1.2 of Please address this by either:
Affected locations:
🧰 Tools🪛 GitHub Check: test / test[failure] 1-1: 🤖 Prompt for AI Agents |
||
| import { createActorContext } from "@xstate/react" | ||
| import type { PropsWithChildren, ReactElement, ReactNode } from "react" | ||
| import { useFormContext } from "react-hook-form" | ||
|
|
@@ -10,10 +11,6 @@ | |
| fromPromise, | ||
| } from "xstate" | ||
| import type { SwappableToken } from "../../../types/swap" | ||
| import type { | ||
| WalletMessage, | ||
| WalletSignatureResult, | ||
| } from "../../../types/walletMessage" | ||
| import { computeTotalDeltaDifferentDecimals } from "../../../utils/tokenUtils" | ||
| import { swapIntentMachine } from "../../machines/swapIntentMachine" | ||
| import { swapUIMachine } from "../../machines/swapUIMachine1Click" | ||
|
|
@@ -53,7 +50,9 @@ | |
| initialTokenIn?: SwappableToken | ||
| initialTokenOut?: SwappableToken | ||
| tokenList: SwappableToken[] | ||
| signMessage: (params: WalletMessage) => Promise<WalletSignatureResult | null> | ||
| signMessage: ( | ||
| params: walletMessage.WalletMessage | ||
| ) => Promise<walletMessage.WalletSignatureResult | null> | ||
| referral?: string | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| import { | ||
| messageFactory, | ||
| type walletMessage, | ||
| } from "@defuse-protocol/internal-utils" | ||
|
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify external package exports for messageFactory and walletMessage. The import changes look correct, but static analysis failures in other files indicate that Verify that the external package properly exports these members: 🏁 Script executed: #!/bin/bash
# Description: Check if the external package exports the required members
# Expected: Package should export messageFactory and walletMessage namespaces
# Check if the package is installed and what it exports
npm list @defuse-protocol/internal-utils || echo "Package not found"
# Check the package.json and main entry point
if [ -d "node_modules/@defuse-protocol/internal-utils" ]; then
echo "=== Package.json ==="
cat node_modules/@defuse-protocol/internal-utils/package.json | jq '.main, .types, .exports'
echo "=== Main entry exports ==="
if [ -f "node_modules/@defuse-protocol/internal-utils/dist/index.d.ts" ]; then
head -50 node_modules/@defuse-protocol/internal-utils/dist/index.d.ts
elif [ -f "node_modules/@defuse-protocol/internal-utils/index.d.ts" ]; then
head -50 node_modules/@defuse-protocol/internal-utils/index.d.ts
fi
fiLength of output: 220 Missing dependency and export verification for It appears import {
messageFactory,
type walletMessage,
} from "@defuse-protocol/internal-utils"Please address this as follows:
Affected file:
🤖 Prompt for AI Agents |
||
| import { base64 } from "@scure/base" | ||
| import type { MultiPayload } from "src/types/defuse-contracts-types" | ||
|
|
||
| import { type PromiseActorLogic, assertEvent, setup } from "xstate" | ||
| import { | ||
| type SignerCredentials, | ||
|
|
@@ -15,12 +18,7 @@ import type { | |
| TokenValue, | ||
| UnifiedTokenInfo, | ||
| } from "../../../types/base" | ||
| import type { | ||
| WalletMessage, | ||
| WalletSignatureResult, | ||
| } from "../../../types/walletMessage" | ||
| import { findError } from "../../../utils/errors" | ||
| import { randomDefuseNonce } from "../../../utils/messageFactory" | ||
| import { | ||
| adjustDecimals, | ||
| getAnyBaseTokenInfo, | ||
|
|
@@ -60,7 +58,7 @@ export type GiftMakerSignActorOutput = | |
| value: { | ||
| multiPayload: MultiPayload | ||
| signerCredentials: SignerCredentials | ||
| signatureResult: WalletSignatureResult | ||
| signatureResult: walletMessage.WalletSignatureResult | ||
| escrowCredentials: EscrowCredentials | ||
| giftId: string | ||
| } | ||
|
|
@@ -69,7 +67,7 @@ export type GiftMakerSignActorOutput = | |
| export type GiftMakerSignActorContext = { | ||
| parsed: GiftMakerSignActorInput["parsed"] | ||
| signerCredentials: GiftMakerSignActorInput["signerCredentials"] | ||
| walletMessage: WalletMessage | ||
| walletMessage: walletMessage.WalletMessage | ||
| escrowCredentials: EscrowCredentials | ||
| } | ||
|
|
||
|
|
@@ -185,7 +183,7 @@ export const giftMakerSignActor = setup({ | |
| value: { | ||
| ...event.output.value, | ||
| escrowCredentials: context.escrowCredentials, | ||
| giftId: base64.encode(randomDefuseNonce()), | ||
| giftId: base64.encode(messageFactory.randomDefuseNonce()), | ||
| }, | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: External package missing required exports.
The pipeline failure and static analysis clearly indicate that multiple required exports are missing from
@defuse-protocol/internal-utils:authIdentity(pipeline failure)prepareBroadcastRequest(static analysis)walletMessage(static analysis)AuthMethod(not exported)This confirms a dependency issue where this PR requires the related changes from defuse-protocol/sdk-monorepo#60 to be merged first.
🧰 Tools
🪛 GitHub Check: test / test
[failure] 5-5:
Module '"@defuse-protocol/internal-utils"' has no exported member 'walletMessage'.
[failure] 5-5:
Module '"@defuse-protocol/internal-utils"' declares 'AuthMethod' locally, but it is not exported.
[failure] 3-3:
Module '"@defuse-protocol/internal-utils"' has no exported member 'prepareBroadcastRequest'.
[failure] 2-2:
Module '"@defuse-protocol/internal-utils"' has no exported member 'authIdentity'.
🪛 GitHub Actions: CI
[error] 2-2: TypeScript error TS2305: Module '@defuse-protocol/internal-utils' has no exported member 'authIdentity'.
🤖 Prompt for AI Agents