@continuumdao/ctm-mpc-defi 0.2.58 → 0.2.60
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/agent/catalog.cjs +1 -1
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.js +1 -1
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/railgun/SKILL.md +2 -2
- package/dist/protocols/evm/railgun/index.cjs +28 -8
- package/dist/protocols/evm/railgun/index.cjs.map +1 -1
- package/dist/protocols/evm/railgun/index.d.ts +3 -1
- package/dist/protocols/evm/railgun/index.js +29 -10
- package/dist/protocols/evm/railgun/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -29,8 +29,8 @@ Call `ctm_railgun_ensure_wallet` first. Use the returned `railgunAddress` as the
|
|
|
29
29
|
|
|
30
30
|
## Shield
|
|
31
31
|
|
|
32
|
-
1. Call `ctm_railgun_build_shield_multisign` without `shieldSignature`, with `railgunAddress` from `ctm_railgun_ensure_wallet`. Submit that personal_sign request.
|
|
33
|
-
2.
|
|
32
|
+
1. Call `ctm_railgun_build_shield_multisign` without `shieldSignature`, with `railgunAddress` from `ctm_railgun_ensure_wallet`. Submit that personal_sign request (`sign_request_agree`, then `trigger_sign_result`).
|
|
33
|
+
2. `broadcast_sign_result` on that request returns the shield-key signature in `txHashes[0]` and does not send a transaction. Call this tool again with `shieldSignature` set to that hex. Submit the resulting approve-and-shield transaction.
|
|
34
34
|
|
|
35
35
|
The first call signs Railgun's shield message. The second call builds the EVM shield. If allowance is short, the second call includes an approve, and a zero-approve reset when a non-zero allowance is still too small. Shielding spends the KeyGen threshold key, not the 0zk spending key.
|
|
36
36
|
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
var viem = require('viem');
|
|
4
4
|
var continuumNodeSdk = require('@continuumdao/continuum-node-sdk');
|
|
5
5
|
var sharedModels = require('@railgun-community/shared-models');
|
|
6
|
-
var module$1 = require('module');
|
|
7
|
-
var path = require('path');
|
|
8
6
|
|
|
9
7
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
8
|
// src/core/registry.ts
|
|
@@ -544,7 +542,8 @@ async function buildEvmMultisignBatch(args) {
|
|
|
544
542
|
}
|
|
545
543
|
return result;
|
|
546
544
|
}
|
|
547
|
-
|
|
545
|
+
|
|
546
|
+
// src/protocols/evm/railgun/engine.ts
|
|
548
547
|
var artifacts = /* @__PURE__ */ new Map();
|
|
549
548
|
var started = false;
|
|
550
549
|
var loadedProviders = /* @__PURE__ */ new Set();
|
|
@@ -581,17 +580,26 @@ var artifactStore = {
|
|
|
581
580
|
return artifacts.has(path);
|
|
582
581
|
}
|
|
583
582
|
};
|
|
584
|
-
async function
|
|
585
|
-
if (
|
|
586
|
-
|
|
583
|
+
async function attachEngineErrorLogger() {
|
|
584
|
+
if (typeof window !== "undefined") return;
|
|
585
|
+
if (typeof process === "undefined" || !process.versions?.node) return;
|
|
586
|
+
const load = new Function("id", "return import(id)");
|
|
587
|
+
const nodeModule = await load("node:module");
|
|
588
|
+
const nodePath = await load("node:path");
|
|
589
|
+
const require2 = nodeModule.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
587
590
|
const walletEntry = require2.resolve("@railgun-community/wallet");
|
|
588
|
-
const { setLoggers } = require2(
|
|
591
|
+
const { setLoggers } = require2(nodePath.join(nodePath.dirname(walletEntry), "utils/logger.js"));
|
|
589
592
|
setLoggers(
|
|
590
593
|
() => void 0,
|
|
591
594
|
(err) => {
|
|
592
595
|
lastEngineError = errorChain(err);
|
|
593
596
|
}
|
|
594
597
|
);
|
|
598
|
+
}
|
|
599
|
+
async function ensureRailgunEngine() {
|
|
600
|
+
if (started) return;
|
|
601
|
+
const wallet = await walletModule();
|
|
602
|
+
await attachEngineErrorLogger();
|
|
595
603
|
const memdown = (await import('memdown')).default;
|
|
596
604
|
const store = new wallet.ArtifactStore(
|
|
597
605
|
(path) => artifactStore.get(path),
|
|
@@ -654,6 +662,16 @@ async function shieldSignatureMessage() {
|
|
|
654
662
|
const wallet = await import('@railgun-community/wallet');
|
|
655
663
|
return wallet.getShieldPrivateKeySignatureMessage();
|
|
656
664
|
}
|
|
665
|
+
function shieldPrivateKeyFromSignature(signature) {
|
|
666
|
+
const hex = signature.startsWith("0x") ? signature : `0x${signature}`;
|
|
667
|
+
if (!/^0x[0-9a-fA-F]+$/.test(hex) || (hex.length - 2) % 2 !== 0) {
|
|
668
|
+
throw new Error("Shield-key signature must be hex.");
|
|
669
|
+
}
|
|
670
|
+
if ((hex.length - 2) / 2 !== 65) {
|
|
671
|
+
throw new Error("Shield-key signature must be the 65-byte personal_sign of RAILGUN_SHIELD.");
|
|
672
|
+
}
|
|
673
|
+
return viem.keccak256(hex);
|
|
674
|
+
}
|
|
657
675
|
function personalSignBody(args, message) {
|
|
658
676
|
const executor = viem.getAddress(args.executorAddress);
|
|
659
677
|
const digest = viem.hashMessage(message);
|
|
@@ -734,6 +752,7 @@ async function buildEvmMultisignBodyRailgunShield(args) {
|
|
|
734
752
|
if (!signature) {
|
|
735
753
|
return personalSignBody(args, await shieldSignatureMessage());
|
|
736
754
|
}
|
|
755
|
+
const shieldPrivateKey = shieldPrivateKeyFromSignature(signature);
|
|
737
756
|
const network = await railgunNetworkByChainId(args.chainId);
|
|
738
757
|
if (!network) throw new Error("Railgun is not deployed on this chain.");
|
|
739
758
|
const tokenAddress = viem.getAddress(args.tokenAddress);
|
|
@@ -785,7 +804,7 @@ async function buildEvmMultisignBodyRailgunShield(args) {
|
|
|
785
804
|
const populated = await populate(
|
|
786
805
|
sharedModels.TXIDVersion.V2_PoseidonMerkle,
|
|
787
806
|
networkName,
|
|
788
|
-
|
|
807
|
+
shieldPrivateKey,
|
|
789
808
|
[{ tokenAddress, amount, recipientAddress: args.railgunAddress.trim() }],
|
|
790
809
|
[],
|
|
791
810
|
railgunGasDetails(args.chainDetail, 1200000n)
|
|
@@ -1255,6 +1274,7 @@ exports.setRailgunPopulateShieldForTests = setRailgunPopulateShieldForTests;
|
|
|
1255
1274
|
exports.setRailgunShieldLogReaderForTests = setRailgunShieldLogReaderForTests;
|
|
1256
1275
|
exports.setRailgunWalletSession = setRailgunWalletSession;
|
|
1257
1276
|
exports.shieldIndexEndpoint = shieldIndexEndpoint;
|
|
1277
|
+
exports.shieldPrivateKeyFromSignature = shieldPrivateKeyFromSignature;
|
|
1258
1278
|
exports.unlockRailgunBrowserWallet = unlockRailgunBrowserWallet;
|
|
1259
1279
|
exports.utxoScanTerminalStatus = utxoScanTerminalStatus;
|
|
1260
1280
|
//# sourceMappingURL=index.cjs.map
|