@pear-protocol/symmio-client 0.3.9 → 0.3.11
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.
- package/dist/index.js +65 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -37
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +0 -3
- package/dist/react/index.d.ts +0 -3
- package/dist/react/index.js +65 -38
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +65 -38
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.mts
CHANGED
|
@@ -46,9 +46,6 @@ declare function useSymmAuth(params?: UseSymmAuthParams): {
|
|
|
46
46
|
signIn: (accountAddress?: Address, options?: {
|
|
47
47
|
force?: boolean;
|
|
48
48
|
}) => Promise<string | null>;
|
|
49
|
-
refreshAuth: (accountAddress?: Address, options?: {
|
|
50
|
-
force?: boolean;
|
|
51
|
-
}) => Promise<string | null>;
|
|
52
49
|
clear: () => void;
|
|
53
50
|
};
|
|
54
51
|
|
package/dist/react/index.d.ts
CHANGED
|
@@ -46,9 +46,6 @@ declare function useSymmAuth(params?: UseSymmAuthParams): {
|
|
|
46
46
|
signIn: (accountAddress?: Address, options?: {
|
|
47
47
|
force?: boolean;
|
|
48
48
|
}) => Promise<string | null>;
|
|
49
|
-
refreshAuth: (accountAddress?: Address, options?: {
|
|
50
|
-
force?: boolean;
|
|
51
|
-
}) => Promise<string | null>;
|
|
52
49
|
clear: () => void;
|
|
53
50
|
};
|
|
54
51
|
|
package/dist/react/index.js
CHANGED
|
@@ -1132,7 +1132,6 @@ function useSymmAuth(params) {
|
|
|
1132
1132
|
isAuthenticated: !!token,
|
|
1133
1133
|
error,
|
|
1134
1134
|
signIn,
|
|
1135
|
-
refreshAuth: signIn,
|
|
1136
1135
|
clear: clearAuth
|
|
1137
1136
|
};
|
|
1138
1137
|
}
|
|
@@ -25087,68 +25086,96 @@ async function internalTransfer(walletClient, publicClient, multiAccount, subAcc
|
|
|
25087
25086
|
}
|
|
25088
25087
|
|
|
25089
25088
|
// src/clients/muon.ts
|
|
25090
|
-
function
|
|
25091
|
-
|
|
25092
|
-
|
|
25093
|
-
|
|
25094
|
-
|
|
25095
|
-
|
|
25089
|
+
function normalizeSignParams(raw) {
|
|
25090
|
+
if (Array.isArray(raw)) {
|
|
25091
|
+
const out = {};
|
|
25092
|
+
for (const entry of raw) {
|
|
25093
|
+
if (entry && typeof entry === "object" && "name" in entry) {
|
|
25094
|
+
const e = entry;
|
|
25095
|
+
out[e.name] = e.value;
|
|
25096
|
+
}
|
|
25097
|
+
}
|
|
25098
|
+
return out;
|
|
25099
|
+
}
|
|
25100
|
+
return raw ?? {};
|
|
25096
25101
|
}
|
|
25097
|
-
function
|
|
25102
|
+
function unwrapMuonResult(result) {
|
|
25098
25103
|
const data = result["result"];
|
|
25099
25104
|
if (!data) {
|
|
25100
25105
|
throw new SymmioSDKError("Invalid Muon response: missing result", "MUON_PARSE_ERROR");
|
|
25101
25106
|
}
|
|
25102
25107
|
const sigData = data["data"];
|
|
25103
|
-
|
|
25104
|
-
|
|
25108
|
+
return {
|
|
25109
|
+
signParams: normalizeSignParams(sigData?.["signParams"] ?? data["signParams"]),
|
|
25110
|
+
signatures: sigData?.["signatures"] ?? data["signatures"] ?? [],
|
|
25111
|
+
init: sigData?.["init"] ?? data["init"]
|
|
25112
|
+
};
|
|
25113
|
+
}
|
|
25114
|
+
function extractSchnorrSign(signParams, signatures, init) {
|
|
25115
|
+
const inline = signParams["sigs"];
|
|
25116
|
+
if (inline?.signature !== void 0) {
|
|
25117
|
+
return {
|
|
25118
|
+
signature: BigInt(inline.signature),
|
|
25119
|
+
owner: inline.owner,
|
|
25120
|
+
nonce: inline.nonce
|
|
25121
|
+
};
|
|
25122
|
+
}
|
|
25123
|
+
const sig = signatures?.[0];
|
|
25124
|
+
if (!sig?.["signature"]) {
|
|
25125
|
+
throw new SymmioSDKError(
|
|
25126
|
+
"Invalid Muon response: missing schnorr signature",
|
|
25127
|
+
"MUON_PARSE_ERROR"
|
|
25128
|
+
);
|
|
25129
|
+
}
|
|
25130
|
+
const nonceAddress = init?.["nonceAddress"] ?? sig["nonce"] ?? signParams["nonce"];
|
|
25131
|
+
if (!nonceAddress) {
|
|
25132
|
+
throw new SymmioSDKError(
|
|
25133
|
+
"Invalid Muon response: missing nonce address",
|
|
25134
|
+
"MUON_PARSE_ERROR"
|
|
25135
|
+
);
|
|
25136
|
+
}
|
|
25137
|
+
return {
|
|
25138
|
+
signature: BigInt(sig["signature"]),
|
|
25139
|
+
owner: sig["owner"],
|
|
25140
|
+
nonce: nonceAddress
|
|
25141
|
+
};
|
|
25142
|
+
}
|
|
25143
|
+
function gatewaySigOf(signatures) {
|
|
25144
|
+
return signatures?.[0]?.["signature"] ?? "0x";
|
|
25145
|
+
}
|
|
25146
|
+
function parseSingleUpnlSig(result) {
|
|
25147
|
+
const { signParams, signatures, init } = unwrapMuonResult(result);
|
|
25105
25148
|
return {
|
|
25106
25149
|
reqId: signParams["reqId"],
|
|
25107
25150
|
timestamp: BigInt(signParams["timestamp"]),
|
|
25108
25151
|
upnl: BigInt(signParams["upnl"]),
|
|
25109
|
-
gatewaySignature: signatures
|
|
25110
|
-
sigs:
|
|
25111
|
-
signParams["sigs"] ?? signatures?.[1]
|
|
25112
|
-
)
|
|
25152
|
+
gatewaySignature: gatewaySigOf(signatures),
|
|
25153
|
+
sigs: extractSchnorrSign(signParams, signatures, init)
|
|
25113
25154
|
};
|
|
25114
25155
|
}
|
|
25115
25156
|
function parseSingleUpnlAndPriceSig(result) {
|
|
25116
|
-
const
|
|
25117
|
-
if (!data) {
|
|
25118
|
-
throw new SymmioSDKError("Invalid Muon response: missing result", "MUON_PARSE_ERROR");
|
|
25119
|
-
}
|
|
25120
|
-
const sigData = data["data"];
|
|
25121
|
-
const signParams = sigData?.["signParams"] ?? data["signParams"];
|
|
25122
|
-
const signatures = sigData?.["signatures"] ?? data["signatures"];
|
|
25157
|
+
const { signParams, signatures, init } = unwrapMuonResult(result);
|
|
25123
25158
|
return {
|
|
25124
25159
|
reqId: signParams["reqId"],
|
|
25125
25160
|
timestamp: BigInt(signParams["timestamp"]),
|
|
25126
25161
|
upnl: BigInt(signParams["upnl"]),
|
|
25127
25162
|
price: BigInt(signParams["price"]),
|
|
25128
|
-
gatewaySignature: signatures
|
|
25129
|
-
sigs:
|
|
25130
|
-
signParams["sigs"] ?? signatures?.[1]
|
|
25131
|
-
)
|
|
25163
|
+
gatewaySignature: gatewaySigOf(signatures),
|
|
25164
|
+
sigs: extractSchnorrSign(signParams, signatures, init)
|
|
25132
25165
|
};
|
|
25133
25166
|
}
|
|
25134
25167
|
function parseBatchSig(result) {
|
|
25135
|
-
const
|
|
25136
|
-
|
|
25137
|
-
|
|
25138
|
-
}
|
|
25139
|
-
const sigData = data["data"];
|
|
25140
|
-
const signParams = sigData?.["signParams"] ?? data["signParams"];
|
|
25141
|
-
const signatures = sigData?.["signatures"] ?? data["signatures"];
|
|
25168
|
+
const { signParams, signatures, init } = unwrapMuonResult(result);
|
|
25169
|
+
const prices = signParams["prices"];
|
|
25170
|
+
const symbolIds = signParams["symbolIds"];
|
|
25142
25171
|
return {
|
|
25143
25172
|
reqId: signParams["reqId"],
|
|
25144
25173
|
timestamp: BigInt(signParams["timestamp"]),
|
|
25145
25174
|
upnl: BigInt(signParams["upnl"]),
|
|
25146
|
-
prices:
|
|
25147
|
-
symbolIds:
|
|
25148
|
-
gatewaySignature: signatures
|
|
25149
|
-
sigs:
|
|
25150
|
-
signParams["sigs"] ?? signatures?.[1]
|
|
25151
|
-
)
|
|
25175
|
+
prices: (prices ?? []).map((p) => BigInt(p)),
|
|
25176
|
+
symbolIds: (symbolIds ?? []).map((s) => BigInt(s)),
|
|
25177
|
+
gatewaySignature: gatewaySigOf(signatures),
|
|
25178
|
+
sigs: extractSchnorrSign(signParams, signatures, init)
|
|
25152
25179
|
};
|
|
25153
25180
|
}
|
|
25154
25181
|
var MuonClient = class {
|