@arca-network/sdk 1.5.2 → 1.7.0
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/arca.d.ts +60 -3
- package/dist/arca.d.ts.map +1 -1
- package/dist/arca.js +106 -2
- package/dist/arca.js.map +1 -1
- package/dist/client.d.ts +29 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +18 -6
- package/dist/client.js.map +1 -1
- package/dist/cosign.d.ts +208 -0
- package/dist/cosign.d.ts.map +1 -0
- package/dist/cosign.js +488 -0
- package/dist/cosign.js.map +1 -0
- package/dist/errors.d.ts +28 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +43 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -1
- package/dist/index.js.map +1 -1
- package/dist/streams.d.ts +32 -2
- package/dist/streams.d.ts.map +1 -1
- package/dist/streams.js +119 -3
- package/dist/streams.js.map +1 -1
- package/dist/types.d.ts +131 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -1
- package/dist/websocket.d.ts +24 -1
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js +127 -1
- package/dist/websocket.js.map +1 -1
- package/package.json +1 -1
package/dist/cosign.js
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CosignerManageAction = exports.ZERO_BYTES32 = exports.OPERATOR_ACTION_TYPEHASH_HEX = exports.CosignAction = void 0;
|
|
4
|
+
exports.domainSeparator = domainSeparator;
|
|
5
|
+
exports.operatorActionDigest = operatorActionDigest;
|
|
6
|
+
exports.signOperatorAction = signOperatorAction;
|
|
7
|
+
exports.recoverOperatorActionSigner = recoverOperatorActionSigner;
|
|
8
|
+
exports.moveOutParamsHash = moveOutParamsHash;
|
|
9
|
+
exports.withdrawParamsHash = withdrawParamsHash;
|
|
10
|
+
exports.crossTransferParamsHash = crossTransferParamsHash;
|
|
11
|
+
exports.routeToModuleParamsHash = routeToModuleParamsHash;
|
|
12
|
+
exports.vaultAddAgentParamsHash = vaultAddAgentParamsHash;
|
|
13
|
+
exports.vaultDrainParamsHash = vaultDrainParamsHash;
|
|
14
|
+
exports.vaultBridgeParamsHash = vaultBridgeParamsHash;
|
|
15
|
+
exports.vaultMigrateParentParamsHash = vaultMigrateParentParamsHash;
|
|
16
|
+
exports.signWithdraw = signWithdraw;
|
|
17
|
+
exports.signCrossTransfer = signCrossTransfer;
|
|
18
|
+
exports.signRouteToModule = signRouteToModule;
|
|
19
|
+
exports.signVaultAddAgent = signVaultAddAgent;
|
|
20
|
+
exports.signVaultDrain = signVaultDrain;
|
|
21
|
+
exports.signVaultBridge = signVaultBridge;
|
|
22
|
+
exports.signVaultMigrateParent = signVaultMigrateParent;
|
|
23
|
+
exports.addressDeviceSigner = addressDeviceSigner;
|
|
24
|
+
exports.verifierDeviceSigner = verifierDeviceSigner;
|
|
25
|
+
exports.p256DeviceKey = p256DeviceKey;
|
|
26
|
+
exports.p256DeviceSigner = p256DeviceSigner;
|
|
27
|
+
exports.encodeP256Signature = encodeP256Signature;
|
|
28
|
+
exports.deviceSignerHash = deviceSignerHash;
|
|
29
|
+
exports.encodeRegistryCosignBlob = encodeRegistryCosignBlob;
|
|
30
|
+
exports.cosignRegistryDomainSeparator = cosignRegistryDomainSeparator;
|
|
31
|
+
exports.cosignerManageDigest = cosignerManageDigest;
|
|
32
|
+
exports.signCosignerManage = signCosignerManage;
|
|
33
|
+
exports.recoverCosignerManageSigner = recoverCosignerManageSigner;
|
|
34
|
+
const sha3_js_1 = require("@noble/hashes/sha3.js");
|
|
35
|
+
const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
|
|
36
|
+
/**
|
|
37
|
+
* Client-side EIP-712 co-signing for the Arca v2 custody kernel
|
|
38
|
+
* (`OperatorAction`).
|
|
39
|
+
*
|
|
40
|
+
* On a co-sign-enabled boundary the kernel will not move value on an
|
|
41
|
+
* operator-initiated action unless the action carries a fresh user
|
|
42
|
+
* signature over an `OperatorAction` typed-data digest. The user's device
|
|
43
|
+
* (which holds the boundary's secp256k1 co-sign key, typically unlocked via
|
|
44
|
+
* a passkey) produces that signature; the operator submits it on-chain. The
|
|
45
|
+
* operator controls the timing of the action but cannot move value without
|
|
46
|
+
* this signature.
|
|
47
|
+
*
|
|
48
|
+
* This module builds the exact digest the kernel verifies in
|
|
49
|
+
* `ArcaCustodyKernel._verifyCosign` / `hashOperatorAction`:
|
|
50
|
+
* domain = EIP712Domain(name="ArcaCustodyKernel", version="1",
|
|
51
|
+
* chainId, verifyingContract=kernel)
|
|
52
|
+
* struct = OperatorAction(uint8 actionType, bytes32 boundary,
|
|
53
|
+
* bytes32 paramsHash, uint256 nonce,
|
|
54
|
+
* uint256 deadline)
|
|
55
|
+
* digest = keccak256(0x1901 ‖ domainSeparator ‖ structHash)
|
|
56
|
+
*
|
|
57
|
+
* It is built on the same `@noble` primitives the SDK already uses for
|
|
58
|
+
* recovery-key generation — no viem/ethers dependency.
|
|
59
|
+
*
|
|
60
|
+
* NOTE on the signer: a secp256k1 EOA signature (this module) is verified
|
|
61
|
+
* on-chain via `ecrecover`. The kernel also accepts ERC-1271 signatures, so
|
|
62
|
+
* a smart-contract / passkey-fronted signer is supported on-chain — but
|
|
63
|
+
* producing those is the signer contract's concern, not this module's.
|
|
64
|
+
*/
|
|
65
|
+
// --- Action discriminator (STABLE — part of the signed digest) ---
|
|
66
|
+
/**
|
|
67
|
+
* Mirrors `IArcaCustodyKernel.CosignAction`. The integer values are folded
|
|
68
|
+
* into the EIP-712 digest and MUST stay in lockstep with that enum; once the
|
|
69
|
+
* contracts are deployed this is a frozen wire contract.
|
|
70
|
+
*
|
|
71
|
+
* `MoveOut` (0) is the kernel's single generic value-out primitive. The
|
|
72
|
+
* coordinator composes it as both a plain withdraw (`context = 0`) and a
|
|
73
|
+
* venue route (`context = moduleAccountId`), so one discriminator covers what
|
|
74
|
+
* were previously the separate `Withdraw` and `RouteToModule` actions.
|
|
75
|
+
*/
|
|
76
|
+
var CosignAction;
|
|
77
|
+
(function (CosignAction) {
|
|
78
|
+
CosignAction[CosignAction["MoveOut"] = 0] = "MoveOut";
|
|
79
|
+
CosignAction[CosignAction["CrossTransfer"] = 1] = "CrossTransfer";
|
|
80
|
+
CosignAction[CosignAction["VaultAddAgent"] = 2] = "VaultAddAgent";
|
|
81
|
+
CosignAction[CosignAction["VaultDrain"] = 3] = "VaultDrain";
|
|
82
|
+
CosignAction[CosignAction["VaultBridge"] = 4] = "VaultBridge";
|
|
83
|
+
CosignAction[CosignAction["SetCoordinator"] = 5] = "SetCoordinator";
|
|
84
|
+
CosignAction[CosignAction["MigrateOut"] = 6] = "MigrateOut";
|
|
85
|
+
CosignAction[CosignAction["VaultMigrateParent"] = 7] = "VaultMigrateParent";
|
|
86
|
+
})(CosignAction || (exports.CosignAction = CosignAction = {}));
|
|
87
|
+
// --- Typed-data constants (must match the kernel) ---
|
|
88
|
+
const DOMAIN_NAME = 'ArcaCustodyKernel';
|
|
89
|
+
const DOMAIN_VERSION = '1';
|
|
90
|
+
const EIP712_DOMAIN_TYPEHASH = keccak256Hex('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)');
|
|
91
|
+
const OPERATOR_ACTION_TYPEHASH = keccak256Hex('OperatorAction(uint8 actionType,bytes32 boundary,bytes32 paramsHash,uint256 nonce,uint256 deadline)');
|
|
92
|
+
/** Exposed for cross-checking against the on-chain constant. */
|
|
93
|
+
exports.OPERATOR_ACTION_TYPEHASH_HEX = '0x' + OPERATOR_ACTION_TYPEHASH;
|
|
94
|
+
// --- Digest ---
|
|
95
|
+
/** EIP-712 domain separator for a kernel on a given chain. */
|
|
96
|
+
function domainSeparator(chainId, kernelAddress) {
|
|
97
|
+
const data = concat(hexToBytes(EIP712_DOMAIN_TYPEHASH), keccak256(utf8(DOMAIN_NAME)), keccak256(utf8(DOMAIN_VERSION)), encodeUint(chainId), encodeAddress(kernelAddress));
|
|
98
|
+
return '0x' + bytesToHex(keccak256(data));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The EIP-712 digest a co-sign key must sign. Equal to the kernel's
|
|
102
|
+
* `hashOperatorAction(actionType, boundary, paramsHash, nonce, deadline)`.
|
|
103
|
+
*/
|
|
104
|
+
function operatorActionDigest(a) {
|
|
105
|
+
const structHash = keccak256(concat(hexToBytes(OPERATOR_ACTION_TYPEHASH), encodeUint(a.action), encodeBytes32(a.boundary), encodeBytes32(a.paramsHash), encodeUint(a.nonce), encodeUint(a.deadline)));
|
|
106
|
+
const ds = hexToBytes(domainSeparator(a.chainId, a.kernelAddress));
|
|
107
|
+
const digest = keccak256(concat(new Uint8Array([0x19, 0x01]), ds, structHash));
|
|
108
|
+
return '0x' + bytesToHex(digest);
|
|
109
|
+
}
|
|
110
|
+
// --- Signing ---
|
|
111
|
+
/**
|
|
112
|
+
* Sign an `OperatorAction` with the boundary's secp256k1 co-sign private
|
|
113
|
+
* key. Returns a 65-byte `0x`-prefixed signature `r ‖ s ‖ v` (v ∈ {27,28}),
|
|
114
|
+
* the layout `ecrecover` / OpenZeppelin `ECDSA.recover` expect. The
|
|
115
|
+
* signature is canonical (low-s), satisfying EIP-2.
|
|
116
|
+
*/
|
|
117
|
+
function signOperatorAction(privateKey, a) {
|
|
118
|
+
const digest = hexToBytes(operatorActionDigest(a));
|
|
119
|
+
return '0x' + signDigest(privateKey, digest);
|
|
120
|
+
}
|
|
121
|
+
/** Recover the signer address from a signature over an `OperatorAction`. */
|
|
122
|
+
function recoverOperatorActionSigner(signature, a) {
|
|
123
|
+
const digest = hexToBytes(operatorActionDigest(a));
|
|
124
|
+
return recoverAddress(signature, digest);
|
|
125
|
+
}
|
|
126
|
+
// --- paramsHash builders (must match the kernel's keccak256(abi.encode(...))) ---
|
|
127
|
+
/** A 32-byte zero word — the `context` for a plain withdraw. */
|
|
128
|
+
exports.ZERO_BYTES32 = '0x' + '0'.repeat(64);
|
|
129
|
+
/**
|
|
130
|
+
* kernel.moveOut: keccak256(abi.encode(to, amount, ref, context)). This is the
|
|
131
|
+
* single commitment for every co-signed value-out. `to` is the recipient (a
|
|
132
|
+
* plain withdraw) or the venue module (a route); `context` is `ZERO_BYTES32`
|
|
133
|
+
* for a withdraw, or the venue sub-account id for a route — so the operator
|
|
134
|
+
* cannot redirect a consented venue deposit to a different sub-account.
|
|
135
|
+
*/
|
|
136
|
+
function moveOutParamsHash(to, amount, ref, context) {
|
|
137
|
+
return abiEncodeHash([encodeAddress(to), encodeUint(amount), encodeBytes32(ref), encodeBytes32(context)]);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Convenience wrapper for a plain withdraw — a `moveOut` with `context = 0`.
|
|
141
|
+
* Produces the kernel's `keccak256(abi.encode(recipient, amount, ref, 0))`.
|
|
142
|
+
*/
|
|
143
|
+
function withdrawParamsHash(amount, recipient, ref) {
|
|
144
|
+
return moveOutParamsHash(recipient, amount, ref, exports.ZERO_BYTES32);
|
|
145
|
+
}
|
|
146
|
+
/** kernel.crossTransfer: keccak256(abi.encode(fromB, toB, amount)). */
|
|
147
|
+
function crossTransferParamsHash(fromB, toB, amount) {
|
|
148
|
+
return abiEncodeHash([encodeBytes32(fromB), encodeBytes32(toB), encodeUint(amount)]);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Convenience wrapper for a venue route — a `moveOut` whose `to` is the module
|
|
152
|
+
* and whose `context` is the venue sub-account id. Produces the kernel's
|
|
153
|
+
* `keccak256(abi.encode(module, amount, ref, subjectId))`.
|
|
154
|
+
*/
|
|
155
|
+
function routeToModuleParamsHash(module, subjectId, amount, ref) {
|
|
156
|
+
return moveOutParamsHash(module, amount, ref, subjectId);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* HL module.vaultAddAgent: keccak256(abi.encode(arcaId, agent, name)). The
|
|
160
|
+
* leading `arcaId` binds the co-signature to ONE arca — a boundary can hold
|
|
161
|
+
* several arcas, and the kernel digest only binds `boundary`, so without this
|
|
162
|
+
* an operator could replay the signature against a different arca in the same
|
|
163
|
+
* boundary. `name` is a dynamic string, so this uses full head/tail ABI
|
|
164
|
+
* encoding: two head words (arcaId, agent) then the offset to the string.
|
|
165
|
+
*/
|
|
166
|
+
function vaultAddAgentParamsHash(arcaId, agent, name) {
|
|
167
|
+
// head = arcaId(32) ‖ agent(32) ‖ offset(32); dynamic string tail follows.
|
|
168
|
+
const head = concat(encodeBytes32(arcaId), encodeAddress(agent), encodeUint(0x60));
|
|
169
|
+
const tail = encodeDynamicBytes(utf8(name));
|
|
170
|
+
return '0x' + bytesToHex(keccak256(concat(head, tail)));
|
|
171
|
+
}
|
|
172
|
+
/** HL module.vaultDrainPerpToSpot: keccak256(abi.encode(arcaId, coreAmt)). */
|
|
173
|
+
function vaultDrainParamsHash(arcaId, coreAmt) {
|
|
174
|
+
return abiEncodeHash([encodeBytes32(arcaId), encodeUint(coreAmt)]);
|
|
175
|
+
}
|
|
176
|
+
/** HL module.vaultBridgeAndForwardUSDC: keccak256(abi.encode(arcaId, coreAmt, ref)). */
|
|
177
|
+
function vaultBridgeParamsHash(arcaId, coreAmt, ref) {
|
|
178
|
+
return abiEncodeHash([encodeBytes32(arcaId), encodeUint(coreAmt), encodeBytes32(ref)]);
|
|
179
|
+
}
|
|
180
|
+
/** HL module.migrateVaultParent: keccak256(abi.encode(arcaId, newModule)). */
|
|
181
|
+
function vaultMigrateParentParamsHash(arcaId, newModule) {
|
|
182
|
+
return abiEncodeHash([encodeBytes32(arcaId), encodeAddress(newModule)]);
|
|
183
|
+
}
|
|
184
|
+
function signWithdraw(privateKey, ctx, amount, recipient, ref) {
|
|
185
|
+
return signOperatorAction(privateKey, {
|
|
186
|
+
...ctx,
|
|
187
|
+
action: CosignAction.MoveOut,
|
|
188
|
+
paramsHash: withdrawParamsHash(amount, recipient, ref),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function signCrossTransfer(privateKey, ctx, toBoundary, amount) {
|
|
192
|
+
return signOperatorAction(privateKey, {
|
|
193
|
+
...ctx,
|
|
194
|
+
action: CosignAction.CrossTransfer,
|
|
195
|
+
paramsHash: crossTransferParamsHash(ctx.boundary, toBoundary, amount),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function signRouteToModule(privateKey, ctx, module, subjectId, amount, ref) {
|
|
199
|
+
return signOperatorAction(privateKey, {
|
|
200
|
+
...ctx,
|
|
201
|
+
action: CosignAction.MoveOut,
|
|
202
|
+
paramsHash: routeToModuleParamsHash(module, subjectId, amount, ref),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function signVaultAddAgent(privateKey, ctx, arcaId, agent, name) {
|
|
206
|
+
return signOperatorAction(privateKey, {
|
|
207
|
+
...ctx,
|
|
208
|
+
action: CosignAction.VaultAddAgent,
|
|
209
|
+
paramsHash: vaultAddAgentParamsHash(arcaId, agent, name),
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function signVaultDrain(privateKey, ctx, arcaId, coreAmt) {
|
|
213
|
+
return signOperatorAction(privateKey, {
|
|
214
|
+
...ctx,
|
|
215
|
+
action: CosignAction.VaultDrain,
|
|
216
|
+
paramsHash: vaultDrainParamsHash(arcaId, coreAmt),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function signVaultBridge(privateKey, ctx, arcaId, coreAmt, ref) {
|
|
220
|
+
return signOperatorAction(privateKey, {
|
|
221
|
+
...ctx,
|
|
222
|
+
action: CosignAction.VaultBridge,
|
|
223
|
+
paramsHash: vaultBridgeParamsHash(arcaId, coreAmt, ref),
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
function signVaultMigrateParent(privateKey, ctx, arcaId, newModule) {
|
|
227
|
+
return signOperatorAction(privateKey, {
|
|
228
|
+
...ctx,
|
|
229
|
+
action: CosignAction.VaultMigrateParent,
|
|
230
|
+
paramsHash: vaultMigrateParentParamsHash(arcaId, newModule),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* A 20-byte secp256k1 EOA device, as an ERC-7913 signer. Its `sig` is the
|
|
235
|
+
* 65-byte `signOperatorAction(...)` output (verified on-chain via `ecrecover`).
|
|
236
|
+
*/
|
|
237
|
+
function addressDeviceSigner(address) {
|
|
238
|
+
const b = hexToBytes(address);
|
|
239
|
+
if (b.length !== 20)
|
|
240
|
+
throw new Error(`cosign: device address must be 20 bytes, got ${b.length}`);
|
|
241
|
+
return '0x' + bytesToHex(b);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* A verifier-backed device, as the ERC-7913 blob `verifier (20 bytes) || key`.
|
|
245
|
+
* `verifier` is a singleton `IERC7913SignatureVerifier` (e.g. the deployed
|
|
246
|
+
* `P256Verifier` / `WebAuthnVerifier`); `key` is its opaque public key.
|
|
247
|
+
*/
|
|
248
|
+
function verifierDeviceSigner(verifier, key) {
|
|
249
|
+
const v = hexToBytes(verifier);
|
|
250
|
+
if (v.length !== 20)
|
|
251
|
+
throw new Error(`cosign: verifier must be a 20-byte address, got ${v.length}`);
|
|
252
|
+
return '0x' + bytesToHex(concat(v, hexToBytes(key)));
|
|
253
|
+
}
|
|
254
|
+
/** A P256 / WebAuthn public key `abi.encode(uint256 x, uint256 y)`. */
|
|
255
|
+
function p256DeviceKey(x, y) {
|
|
256
|
+
return '0x' + bytesToHex(concat(encodeUint(x), encodeUint(y)));
|
|
257
|
+
}
|
|
258
|
+
/** A raw-P256 or WebAuthn device signer `verifier || abi.encode(x, y)`. */
|
|
259
|
+
function p256DeviceSigner(verifier, x, y) {
|
|
260
|
+
return verifierDeviceSigner(verifier, p256DeviceKey(x, y));
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* A raw-P256 device signature `abi.encode(uint256 r, uint256 s)` (what
|
|
264
|
+
* `P256Verifier` expects). For a WebAuthn passkey the device produces an
|
|
265
|
+
* assertion instead — `abi.encode(authenticatorData, clientDataJSON,
|
|
266
|
+
* challengeLocation, responseTypeLocation, r, s)`, what `WebAuthnVerifier`
|
|
267
|
+
* expects — assembled by the client's passkey code over `digest` as the
|
|
268
|
+
* challenge; this SDK does not perform the WebAuthn ceremony.
|
|
269
|
+
*/
|
|
270
|
+
function encodeP256Signature(r, s) {
|
|
271
|
+
return '0x' + bytesToHex(concat(encodeUint(r), encodeUint(s)));
|
|
272
|
+
}
|
|
273
|
+
/** `keccak256(signer)` — the registry's per-boundary set membership key. */
|
|
274
|
+
function deviceSignerHash(signer) {
|
|
275
|
+
return '0x' + bytesToHex(keccak256(hexToBytes(signer)));
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Build the registry co-sign blob `abi.encode(bytes[] signers, bytes[] sigs)`,
|
|
279
|
+
* ordered by strictly increasing `keccak256(signer)` (the canonical order the
|
|
280
|
+
* registry requires). Throws on a duplicate device. Pass this as the kernel's
|
|
281
|
+
* `cosignSig` when `cosignKey` points at a `CosignRegistry`.
|
|
282
|
+
*/
|
|
283
|
+
function encodeRegistryCosignBlob(items) {
|
|
284
|
+
if (items.length === 0)
|
|
285
|
+
throw new Error('cosign: no devices');
|
|
286
|
+
const rows = items.map((it) => ({
|
|
287
|
+
signer: hexToBytes(it.signer),
|
|
288
|
+
sig: hexToBytes(it.sig),
|
|
289
|
+
id: keccak256(hexToBytes(it.signer)),
|
|
290
|
+
}));
|
|
291
|
+
rows.sort((a, b) => compareBytes(a.id, b.id));
|
|
292
|
+
for (let i = 1; i < rows.length; i++) {
|
|
293
|
+
if (compareBytes(rows[i - 1].id, rows[i].id) === 0)
|
|
294
|
+
throw new Error('cosign: duplicate device signer');
|
|
295
|
+
}
|
|
296
|
+
const encSigners = encodeBytesArray(rows.map((r) => r.signer));
|
|
297
|
+
const encSigs = encodeBytesArray(rows.map((r) => r.sig));
|
|
298
|
+
// tuple head: offset to signers (0x40), offset to sigs (0x40 + len(signers)).
|
|
299
|
+
const out = concat(encodeUint(0x40), encodeUint(0x40 + encSigners.length), encSigners, encSigs);
|
|
300
|
+
return '0x' + bytesToHex(out);
|
|
301
|
+
}
|
|
302
|
+
// --- CosignRegistry management relay (EIP-712 CosignerManage) ---
|
|
303
|
+
/** Relayed management action ids — part of the signed `CosignerManage` digest. */
|
|
304
|
+
var CosignerManageAction;
|
|
305
|
+
(function (CosignerManageAction) {
|
|
306
|
+
CosignerManageAction[CosignerManageAction["Add"] = 0] = "Add";
|
|
307
|
+
CosignerManageAction[CosignerManageAction["Remove"] = 1] = "Remove";
|
|
308
|
+
})(CosignerManageAction || (exports.CosignerManageAction = CosignerManageAction = {}));
|
|
309
|
+
const REGISTRY_DOMAIN_NAME = 'ArcaCosignRegistry';
|
|
310
|
+
const REGISTRY_DOMAIN_VERSION = '1';
|
|
311
|
+
const COSIGNER_MANAGE_TYPEHASH = keccak256Hex('CosignerManage(uint8 action,bytes32 boundary,bytes32 signerHash,uint256 nonce,uint256 deadline)');
|
|
312
|
+
/** EIP-712 domain separator for a `CosignRegistry` on a given chain. */
|
|
313
|
+
function cosignRegistryDomainSeparator(chainId, registryAddress) {
|
|
314
|
+
const data = concat(hexToBytes(EIP712_DOMAIN_TYPEHASH), keccak256(utf8(REGISTRY_DOMAIN_NAME)), keccak256(utf8(REGISTRY_DOMAIN_VERSION)), encodeUint(chainId), encodeAddress(registryAddress));
|
|
315
|
+
return '0x' + bytesToHex(keccak256(data));
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* The EIP-712 digest a boundary's recovery key signs to relay an enroll/remove
|
|
319
|
+
* to the registry (`addCosignerWithSig` / `removeCosignerWithSig`). Equal to
|
|
320
|
+
* the registry's `manageDigest(action, boundary, signerHash, deadline)`.
|
|
321
|
+
*/
|
|
322
|
+
function cosignerManageDigest(m) {
|
|
323
|
+
const structHash = keccak256(concat(hexToBytes(COSIGNER_MANAGE_TYPEHASH), encodeUint(m.action), encodeBytes32(m.boundary), encodeBytes32(m.signerHash), encodeUint(m.nonce), encodeUint(m.deadline)));
|
|
324
|
+
const ds = hexToBytes(cosignRegistryDomainSeparator(m.chainId, m.registryAddress));
|
|
325
|
+
const digest = keccak256(concat(new Uint8Array([0x19, 0x01]), ds, structHash));
|
|
326
|
+
return '0x' + bytesToHex(digest);
|
|
327
|
+
}
|
|
328
|
+
/** Sign a `CosignerManage` relay authorization with the recovery key. */
|
|
329
|
+
function signCosignerManage(privateKey, m) {
|
|
330
|
+
return '0x' + signDigest(privateKey, hexToBytes(cosignerManageDigest(m)));
|
|
331
|
+
}
|
|
332
|
+
/** Recover the signer of a `CosignerManage` relay signature. */
|
|
333
|
+
function recoverCosignerManageSigner(signature, m) {
|
|
334
|
+
return recoverAddress(signature, hexToBytes(cosignerManageDigest(m)));
|
|
335
|
+
}
|
|
336
|
+
// --- ABI / hashing primitives ---
|
|
337
|
+
/** Lexicographic compare of two byte arrays (for canonical signer ordering). */
|
|
338
|
+
function compareBytes(a, b) {
|
|
339
|
+
const n = Math.min(a.length, b.length);
|
|
340
|
+
for (let i = 0; i < n; i++) {
|
|
341
|
+
if (a[i] !== b[i])
|
|
342
|
+
return a[i] - b[i];
|
|
343
|
+
}
|
|
344
|
+
return a.length - b.length;
|
|
345
|
+
}
|
|
346
|
+
/** ABI-encode a `bytes[]` value (length word, element offsets, padded elements). */
|
|
347
|
+
function encodeBytesArray(items) {
|
|
348
|
+
const n = items.length;
|
|
349
|
+
const elems = items.map(encodeDynamicBytes);
|
|
350
|
+
const parts = [encodeUint(n)];
|
|
351
|
+
let running = n * 32; // offsets are relative to the start of the offsets block
|
|
352
|
+
for (let i = 0; i < n; i++) {
|
|
353
|
+
parts.push(encodeUint(running));
|
|
354
|
+
running += elems[i].length;
|
|
355
|
+
}
|
|
356
|
+
for (const e of elems)
|
|
357
|
+
parts.push(e);
|
|
358
|
+
return concat(...parts);
|
|
359
|
+
}
|
|
360
|
+
function abiEncodeHash(words) {
|
|
361
|
+
return '0x' + bytesToHex(keccak256(concat(...words)));
|
|
362
|
+
}
|
|
363
|
+
function keccak256(data) {
|
|
364
|
+
return (0, sha3_js_1.keccak_256)(data);
|
|
365
|
+
}
|
|
366
|
+
function keccak256Hex(s) {
|
|
367
|
+
return bytesToHex((0, sha3_js_1.keccak_256)(utf8(s)));
|
|
368
|
+
}
|
|
369
|
+
function utf8(s) {
|
|
370
|
+
return new TextEncoder().encode(s);
|
|
371
|
+
}
|
|
372
|
+
/** Left-pad a value to a 32-byte big-endian word (uintN / actionType). */
|
|
373
|
+
function encodeUint(value) {
|
|
374
|
+
let v;
|
|
375
|
+
if (typeof value === 'bigint')
|
|
376
|
+
v = value;
|
|
377
|
+
else if (typeof value === 'number')
|
|
378
|
+
v = BigInt(value);
|
|
379
|
+
else
|
|
380
|
+
v = BigInt(value); // decimal or 0x string
|
|
381
|
+
if (v < 0n)
|
|
382
|
+
throw new Error('cosign: negative uint');
|
|
383
|
+
const out = new Uint8Array(32);
|
|
384
|
+
for (let i = 31; i >= 0 && v > 0n; i--) {
|
|
385
|
+
out[i] = Number(v & 0xffn);
|
|
386
|
+
v >>= 8n;
|
|
387
|
+
}
|
|
388
|
+
return out;
|
|
389
|
+
}
|
|
390
|
+
/** Left-pad a 20-byte address to a 32-byte word. */
|
|
391
|
+
function encodeAddress(addr) {
|
|
392
|
+
const bytes = hexToBytes(addr);
|
|
393
|
+
if (bytes.length !== 20)
|
|
394
|
+
throw new Error(`cosign: address must be 20 bytes, got ${bytes.length}`);
|
|
395
|
+
const out = new Uint8Array(32);
|
|
396
|
+
out.set(bytes, 12);
|
|
397
|
+
return out;
|
|
398
|
+
}
|
|
399
|
+
/** A bytes32 value, used as-is (must already be 32 bytes). */
|
|
400
|
+
function encodeBytes32(hex) {
|
|
401
|
+
const bytes = hexToBytes(hex);
|
|
402
|
+
if (bytes.length !== 32)
|
|
403
|
+
throw new Error(`cosign: bytes32 must be 32 bytes, got ${bytes.length}`);
|
|
404
|
+
return bytes;
|
|
405
|
+
}
|
|
406
|
+
/** ABI dynamic-bytes tail: length word + right-padded data. */
|
|
407
|
+
function encodeDynamicBytes(data) {
|
|
408
|
+
const len = encodeUint(data.length);
|
|
409
|
+
const padLen = Math.ceil(data.length / 32) * 32;
|
|
410
|
+
const padded = new Uint8Array(padLen);
|
|
411
|
+
padded.set(data, 0);
|
|
412
|
+
return concat(len, padded);
|
|
413
|
+
}
|
|
414
|
+
function concat(...arrays) {
|
|
415
|
+
let total = 0;
|
|
416
|
+
for (const a of arrays)
|
|
417
|
+
total += a.length;
|
|
418
|
+
const out = new Uint8Array(total);
|
|
419
|
+
let off = 0;
|
|
420
|
+
for (const a of arrays) {
|
|
421
|
+
out.set(a, off);
|
|
422
|
+
off += a.length;
|
|
423
|
+
}
|
|
424
|
+
return out;
|
|
425
|
+
}
|
|
426
|
+
function hexToBytes(hex) {
|
|
427
|
+
let h = hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;
|
|
428
|
+
if (h.length % 2 !== 0)
|
|
429
|
+
h = '0' + h;
|
|
430
|
+
const out = new Uint8Array(h.length / 2);
|
|
431
|
+
for (let i = 0; i < out.length; i++) {
|
|
432
|
+
out[i] = parseInt(h.slice(i * 2, i * 2 + 2), 16);
|
|
433
|
+
}
|
|
434
|
+
return out;
|
|
435
|
+
}
|
|
436
|
+
function bytesToHex(bytes) {
|
|
437
|
+
let hex = '';
|
|
438
|
+
for (let i = 0; i < bytes.length; i++)
|
|
439
|
+
hex += bytes[i].toString(16).padStart(2, '0');
|
|
440
|
+
return hex;
|
|
441
|
+
}
|
|
442
|
+
// --- secp256k1 signing / recovery ---
|
|
443
|
+
function normalizePrivKey(privateKey) {
|
|
444
|
+
if (privateKey instanceof Uint8Array)
|
|
445
|
+
return privateKey;
|
|
446
|
+
return hexToBytes(privateKey);
|
|
447
|
+
}
|
|
448
|
+
function signDigest(privateKey, digest) {
|
|
449
|
+
const priv = normalizePrivKey(privateKey);
|
|
450
|
+
// @noble/curves v2: `format: 'recovered'` returns 65 bytes laid out as
|
|
451
|
+
// [recoveryId(1) ‖ r(32) ‖ s(32)]; signatures are canonical (low-s) by
|
|
452
|
+
// default, satisfying EIP-2. We re-pack to the ecrecover layout r‖s‖v.
|
|
453
|
+
const recovered = secp256k1_js_1.secp256k1.sign(digest, priv, { prehash: false, format: 'recovered' });
|
|
454
|
+
if (recovered.length !== 65)
|
|
455
|
+
throw new Error(`cosign: unexpected recovered sig length ${recovered.length}`);
|
|
456
|
+
const recId = recovered[0];
|
|
457
|
+
if (recId !== 0 && recId !== 1)
|
|
458
|
+
throw new Error('cosign: unexpected recovery id');
|
|
459
|
+
const r = recovered.slice(1, 33);
|
|
460
|
+
const s = recovered.slice(33, 65);
|
|
461
|
+
const v = new Uint8Array([recId + 27]);
|
|
462
|
+
return bytesToHex(concat(r, s, v));
|
|
463
|
+
}
|
|
464
|
+
function recoverAddress(signature, digest) {
|
|
465
|
+
const bytes = hexToBytes(signature);
|
|
466
|
+
if (bytes.length !== 65)
|
|
467
|
+
throw new Error(`cosign: signature must be 65 bytes, got ${bytes.length}`);
|
|
468
|
+
const recId = bytes[64] - 27;
|
|
469
|
+
if (recId !== 0 && recId !== 1)
|
|
470
|
+
throw new Error('cosign: bad v byte');
|
|
471
|
+
// Re-assemble the @noble 'recovered' layout: [recoveryId ‖ r ‖ s].
|
|
472
|
+
const recovered = concat(new Uint8Array([recId]), bytes.slice(0, 32), bytes.slice(32, 64));
|
|
473
|
+
const sig = secp256k1_js_1.secp256k1.Signature.fromBytes(recovered, 'recovered');
|
|
474
|
+
const point = sig.recoverPublicKey(digest);
|
|
475
|
+
const pub = point.toBytes(false).subarray(1); // uncompressed, drop 0x04 prefix
|
|
476
|
+
const hash = keccak256(pub);
|
|
477
|
+
return checksumAddress(bytesToHex(hash.slice(-20)));
|
|
478
|
+
}
|
|
479
|
+
/** EIP-55 checksum (mirrors recovery.ts). */
|
|
480
|
+
function checksumAddress(addressHex) {
|
|
481
|
+
const hash = bytesToHex(keccak256(utf8(addressHex)));
|
|
482
|
+
let result = '0x';
|
|
483
|
+
for (let i = 0; i < 40; i++) {
|
|
484
|
+
result += parseInt(hash[i], 16) >= 8 ? addressHex[i].toUpperCase() : addressHex[i];
|
|
485
|
+
}
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
488
|
+
//# sourceMappingURL=cosign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosign.js","sourceRoot":"","sources":["../src/cosign.ts"],"names":[],"mappings":";;;AA8FA,0CASC;AAMD,oDAcC;AAUD,gDAGC;AAGD,kEAGC;AAcD,8CAEC;AAMD,gDAEC;AAGD,0DAEC;AAOD,0DAEC;AAUD,0DAKC;AAGD,oDAEC;AAGD,sDAEC;AAGD,oEAEC;AAYD,oCAYC;AAED,8CAWC;AAED,8CAaC;AAED,8CAYC;AAED,wCAWC;AAED,0CAYC;AAED,wDAWC;AA8BD,kDAIC;AAOD,oDAIC;AAGD,sCAEC;AAGD,4CAEC;AAUD,kDAEC;AAGD,4CAEC;AAQD,4DAgBC;AAiCD,sEASC;AAOD,oDAcC;AAGD,gDAEC;AAGD,kEAEC;AAreD,mDAAmD;AACnD,6DAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,oEAAoE;AAEpE;;;;;;;;;GASG;AACH,IAAY,YASX;AATD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,iEAAiB,CAAA;IACjB,iEAAiB,CAAA;IACjB,2DAAc,CAAA;IACd,6DAAe,CAAA;IACf,mEAAkB,CAAA;IAClB,2DAAc,CAAA;IACd,2EAAsB,CAAA;AACxB,CAAC,EATW,YAAY,4BAAZ,YAAY,QASvB;AAED,uDAAuD;AAEvD,MAAM,WAAW,GAAG,mBAAmB,CAAC;AACxC,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,sBAAsB,GAAG,YAAY,CACzC,oFAAoF,CACrF,CAAC;AACF,MAAM,wBAAwB,GAAG,YAAY,CAC3C,qGAAqG,CACtG,CAAC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6 +20,22 @@ export declare class ValidationError extends ArcaError {
|
|
|
20
20
|
export declare class UnauthorizedError extends ArcaError {
|
|
21
21
|
constructor(message?: string, errorId?: string);
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Thrown when the server refuses a request for lack of permission (403),
|
|
25
|
+
* e.g. `FORBIDDEN` (action not granted on the resource) or
|
|
26
|
+
* `REALM_SCOPE_MISMATCH` (token locked to a different realm).
|
|
27
|
+
*
|
|
28
|
+
* A 403 on a token-provider client commonly means the cached token is
|
|
29
|
+
* still valid but its scope no longer matches what the app is asking for
|
|
30
|
+
* (e.g. the app switched signed-in users). The SDK reacts by re-invoking
|
|
31
|
+
* the token provider once and retrying; an unrecoverable 403 is surfaced
|
|
32
|
+
* through `onAuthError` so integrators can tear down and rebuild.
|
|
33
|
+
*
|
|
34
|
+
* The original server error code is preserved on `code`.
|
|
35
|
+
*/
|
|
36
|
+
export declare class ForbiddenError extends ArcaError {
|
|
37
|
+
constructor(message?: string, errorId?: string, code?: string);
|
|
38
|
+
}
|
|
23
39
|
/**
|
|
24
40
|
* Thrown when a resource is not found (404).
|
|
25
41
|
*/
|
|
@@ -27,10 +43,20 @@ export declare class NotFoundError extends ArcaError {
|
|
|
27
43
|
constructor(message?: string, errorId?: string);
|
|
28
44
|
}
|
|
29
45
|
/**
|
|
30
|
-
* Thrown when there is a conflict (409)
|
|
46
|
+
* Thrown when there is a conflict (409) — the request is well-formed but the
|
|
47
|
+
* current server/venue state can't satisfy it.
|
|
48
|
+
*
|
|
49
|
+
* The specific server code is preserved on `code` so integrators can branch on
|
|
50
|
+
* it. Order-placement conflicts carry actionable codes:
|
|
51
|
+
* - `NO_LIQUIDITY` — the venue book side is empty right now; retry or use a
|
|
52
|
+
* marketable limit.
|
|
53
|
+
* - `MARKET_DELISTED` — the market was delisted; any open position was settled
|
|
54
|
+
* by the venue, and no new orders are accepted (mirrors Hyperliquid).
|
|
55
|
+
*
|
|
56
|
+
* The default code is `CONFLICT` for backwards compatibility.
|
|
31
57
|
*/
|
|
32
58
|
export declare class ConflictError extends ArcaError {
|
|
33
|
-
constructor(message: string, errorId?: string);
|
|
59
|
+
constructor(message: string, errorId?: string, code?: string);
|
|
34
60
|
}
|
|
35
61
|
/**
|
|
36
62
|
* Thrown when the server returns an unexpected error (500).
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC;gBAErB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAM5D;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAI9C;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;gBAClC,OAAO,GAAE,MAA4C,EAAE,OAAO,CAAC,EAAE,MAAM;CAIpF;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,OAAO,GAAE,MAA6B,EAAE,OAAO,CAAC,EAAE,MAAM;CAIrE;AAED
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC;gBAErB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAM5D;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,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strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StepUpCancelledError = exports.StepUpRequiredError = exports.OperationStalledError = exports.OperationFailedError = exports.ExchangeError = exports.InternalError = exports.ConflictError = exports.NotFoundError = exports.UnauthorizedError = exports.ValidationError = exports.ArcaError = void 0;
|
|
3
|
+
exports.StepUpCancelledError = exports.StepUpRequiredError = exports.OperationStalledError = exports.OperationFailedError = exports.ExchangeError = exports.InternalError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.ValidationError = exports.ArcaError = void 0;
|
|
4
4
|
exports.mapApiError = mapApiError;
|
|
5
5
|
/**
|
|
6
6
|
* Base error class for all Arca SDK errors.
|
|
@@ -38,6 +38,26 @@ class UnauthorizedError extends ArcaError {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.UnauthorizedError = UnauthorizedError;
|
|
41
|
+
/**
|
|
42
|
+
* Thrown when the server refuses a request for lack of permission (403),
|
|
43
|
+
* e.g. `FORBIDDEN` (action not granted on the resource) or
|
|
44
|
+
* `REALM_SCOPE_MISMATCH` (token locked to a different realm).
|
|
45
|
+
*
|
|
46
|
+
* A 403 on a token-provider client commonly means the cached token is
|
|
47
|
+
* still valid but its scope no longer matches what the app is asking for
|
|
48
|
+
* (e.g. the app switched signed-in users). The SDK reacts by re-invoking
|
|
49
|
+
* the token provider once and retrying; an unrecoverable 403 is surfaced
|
|
50
|
+
* through `onAuthError` so integrators can tear down and rebuild.
|
|
51
|
+
*
|
|
52
|
+
* The original server error code is preserved on `code`.
|
|
53
|
+
*/
|
|
54
|
+
class ForbiddenError extends ArcaError {
|
|
55
|
+
constructor(message = 'Access denied', errorId, code = 'FORBIDDEN') {
|
|
56
|
+
super(code, message, errorId);
|
|
57
|
+
this.name = 'ForbiddenError';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.ForbiddenError = ForbiddenError;
|
|
41
61
|
/**
|
|
42
62
|
* Thrown when a resource is not found (404).
|
|
43
63
|
*/
|
|
@@ -49,11 +69,21 @@ class NotFoundError extends ArcaError {
|
|
|
49
69
|
}
|
|
50
70
|
exports.NotFoundError = NotFoundError;
|
|
51
71
|
/**
|
|
52
|
-
* Thrown when there is a conflict (409)
|
|
72
|
+
* Thrown when there is a conflict (409) — the request is well-formed but the
|
|
73
|
+
* current server/venue state can't satisfy it.
|
|
74
|
+
*
|
|
75
|
+
* The specific server code is preserved on `code` so integrators can branch on
|
|
76
|
+
* it. Order-placement conflicts carry actionable codes:
|
|
77
|
+
* - `NO_LIQUIDITY` — the venue book side is empty right now; retry or use a
|
|
78
|
+
* marketable limit.
|
|
79
|
+
* - `MARKET_DELISTED` — the market was delisted; any open position was settled
|
|
80
|
+
* by the venue, and no new orders are accepted (mirrors Hyperliquid).
|
|
81
|
+
*
|
|
82
|
+
* The default code is `CONFLICT` for backwards compatibility.
|
|
53
83
|
*/
|
|
54
84
|
class ConflictError extends ArcaError {
|
|
55
|
-
constructor(message, errorId) {
|
|
56
|
-
super(
|
|
85
|
+
constructor(message, errorId, code = 'CONFLICT') {
|
|
86
|
+
super(code, message, errorId);
|
|
57
87
|
this.name = 'ConflictError';
|
|
58
88
|
}
|
|
59
89
|
}
|
|
@@ -203,6 +233,9 @@ function mapApiError(code, message, errorId, details) {
|
|
|
203
233
|
return new ValidationError(message, errorId);
|
|
204
234
|
case 'UNAUTHORIZED':
|
|
205
235
|
return new UnauthorizedError(message, errorId);
|
|
236
|
+
case 'FORBIDDEN':
|
|
237
|
+
case 'REALM_SCOPE_MISMATCH':
|
|
238
|
+
return new ForbiddenError(message, errorId, code);
|
|
206
239
|
case 'NOT_FOUND':
|
|
207
240
|
case 'USER_NOT_FOUND':
|
|
208
241
|
case 'REALM_NOT_FOUND':
|
|
@@ -222,6 +255,12 @@ function mapApiError(code, message, errorId, details) {
|
|
|
222
255
|
case 'ALREADY_REVOKED':
|
|
223
256
|
case 'IDEMPOTENCY_VIOLATION':
|
|
224
257
|
return new ConflictError(message, errorId);
|
|
258
|
+
// Order-placement conflicts (409): well-formed requests the venue state
|
|
259
|
+
// can't fill right now. Preserve the specific code so integrators can
|
|
260
|
+
// branch on "no liquidity, retry" vs "market gone for good".
|
|
261
|
+
case 'NO_LIQUIDITY':
|
|
262
|
+
case 'MARKET_DELISTED':
|
|
263
|
+
return new ConflictError(message, errorId, code);
|
|
225
264
|
case 'INTERNAL_ERROR':
|
|
226
265
|
return new InternalError(message, errorId);
|
|
227
266
|
case 'EXCHANGE_ERROR':
|