@manifest-network/manifest-mcp-core 0.1.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/__test-utils__/callTool.d.ts +29 -0
- package/dist/__test-utils__/callTool.d.ts.map +1 -0
- package/dist/__test-utils__/callTool.js +45 -0
- package/dist/__test-utils__/callTool.js.map +1 -0
- package/dist/__test-utils__/mocks.d.ts +125 -0
- package/dist/__test-utils__/mocks.d.ts.map +1 -0
- package/dist/__test-utils__/mocks.js +146 -0
- package/dist/__test-utils__/mocks.js.map +1 -0
- package/dist/client.d.ts +67 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +209 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +30 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +127 -0
- package/dist/config.js.map +1 -0
- package/dist/cosmos.d.ts +24 -0
- package/dist/cosmos.d.ts.map +1 -0
- package/dist/cosmos.js +85 -0
- package/dist/cosmos.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +20 -0
- package/dist/lcd-adapter.d.ts +15 -0
- package/dist/lcd-adapter.d.ts.map +1 -0
- package/dist/lcd-adapter.js +98 -0
- package/dist/lcd-adapter.js.map +1 -0
- package/dist/logger.d.ts +20 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +43 -0
- package/dist/logger.js.map +1 -0
- package/dist/modules.d.ts +63 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +759 -0
- package/dist/modules.js.map +1 -0
- package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +78 -0
- package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js.map +1 -0
- package/dist/node_modules/@vitest/expect/dist/index.d.ts +802 -0
- package/dist/node_modules/@vitest/expect/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@vitest/expect/dist/index.js +1457 -0
- package/dist/node_modules/@vitest/expect/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/pretty-format/dist/index.d.ts +95 -0
- package/dist/node_modules/@vitest/pretty-format/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@vitest/pretty-format/dist/index.js +877 -0
- package/dist/node_modules/@vitest/pretty-format/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/runner/dist/chunk-tasks.js +91 -0
- package/dist/node_modules/@vitest/runner/dist/chunk-tasks.js.map +1 -0
- package/dist/node_modules/@vitest/runner/dist/index.js +1381 -0
- package/dist/node_modules/@vitest/runner/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts +540 -0
- package/dist/node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts.map +1 -0
- package/dist/node_modules/@vitest/runner/dist/utils.js +1 -0
- package/dist/node_modules/@vitest/snapshot/dist/environment.d-DOJxxZV9.d.ts +16 -0
- package/dist/node_modules/@vitest/snapshot/dist/environment.d-DOJxxZV9.d.ts.map +1 -0
- package/dist/node_modules/@vitest/snapshot/dist/index.d.ts +89 -0
- package/dist/node_modules/@vitest/snapshot/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@vitest/snapshot/dist/index.js +649 -0
- package/dist/node_modules/@vitest/snapshot/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/snapshot/dist/rawSnapshot.d-U2kJUxDr.d.ts +40 -0
- package/dist/node_modules/@vitest/snapshot/dist/rawSnapshot.d-U2kJUxDr.d.ts.map +1 -0
- package/dist/node_modules/@vitest/spy/dist/index.d.ts +343 -0
- package/dist/node_modules/@vitest/spy/dist/index.d.ts.map +1 -0
- package/dist/node_modules/@vitest/spy/dist/index.js +386 -0
- package/dist/node_modules/@vitest/spy/dist/index.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +82 -0
- package/dist/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/diff.d.ts +14 -0
- package/dist/node_modules/@vitest/utils/dist/diff.d.ts.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/diff.js +1297 -0
- package/dist/node_modules/@vitest/utils/dist/diff.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/display.d.ts +15 -0
- package/dist/node_modules/@vitest/utils/dist/display.d.ts.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/display.js +558 -0
- package/dist/node_modules/@vitest/utils/dist/display.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/error.js +30 -0
- package/dist/node_modules/@vitest/utils/dist/error.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/helpers.js +181 -0
- package/dist/node_modules/@vitest/utils/dist/helpers.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/offset.js +27 -0
- package/dist/node_modules/@vitest/utils/dist/offset.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/serialize.js +77 -0
- package/dist/node_modules/@vitest/utils/dist/serialize.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/source-map.js +367 -0
- package/dist/node_modules/@vitest/utils/dist/source-map.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/timers.js +37 -0
- package/dist/node_modules/@vitest/utils/dist/timers.js.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts +38 -0
- package/dist/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts.map +1 -0
- package/dist/node_modules/@vitest/utils/dist/types.d.ts +25 -0
- package/dist/node_modules/@vitest/utils/dist/types.d.ts.map +1 -0
- package/dist/node_modules/chai/index.js +2875 -0
- package/dist/node_modules/chai/index.js.map +1 -0
- package/dist/node_modules/magic-string/dist/magic-string.es.js +939 -0
- package/dist/node_modules/magic-string/dist/magic-string.es.js.map +1 -0
- package/dist/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +85 -0
- package/dist/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js.map +1 -0
- package/dist/node_modules/tinybench/dist/index.d.ts +91 -0
- package/dist/node_modules/tinybench/dist/index.d.ts.map +1 -0
- package/dist/node_modules/tinyrainbow/dist/index.d.ts +9 -0
- package/dist/node_modules/tinyrainbow/dist/index.d.ts.map +1 -0
- package/dist/node_modules/tinyrainbow/dist/index.js +86 -0
- package/dist/node_modules/tinyrainbow/dist/index.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/benchmark.D0SlKNbZ.js +41 -0
- package/dist/node_modules/vitest/dist/chunks/benchmark.D0SlKNbZ.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/benchmark.d.DAaHLpsq.d.ts +12 -0
- package/dist/node_modules/vitest/dist/chunks/benchmark.d.DAaHLpsq.d.ts.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/global.d.x-ILCfAE.d.ts +100 -0
- package/dist/node_modules/vitest/dist/chunks/global.d.x-ILCfAE.d.ts.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +57 -0
- package/dist/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/rpc.d.BFMWpdph.d.ts +13 -0
- package/dist/node_modules/vitest/dist/chunks/rpc.d.BFMWpdph.d.ts.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/test.CTcmp4Su.js +2791 -0
- package/dist/node_modules/vitest/dist/chunks/test.CTcmp4Su.js.map +1 -0
- package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +44 -0
- package/dist/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js.map +1 -0
- package/dist/node_modules/vitest/dist/index.d.ts +9 -0
- package/dist/queries/auth.d.ts +15 -0
- package/dist/queries/auth.d.ts.map +1 -0
- package/dist/queries/auth.js +58 -0
- package/dist/queries/auth.js.map +1 -0
- package/dist/queries/bank.d.ts +15 -0
- package/dist/queries/bank.d.ts.map +1 -0
- package/dist/queries/bank.js +93 -0
- package/dist/queries/bank.js.map +1 -0
- package/dist/queries/billing.d.ts +15 -0
- package/dist/queries/billing.d.ts.map +1 -0
- package/dist/queries/billing.js +114 -0
- package/dist/queries/billing.js.map +1 -0
- package/dist/queries/distribution.d.ts +15 -0
- package/dist/queries/distribution.d.ts.map +1 -0
- package/dist/queries/distribution.js +73 -0
- package/dist/queries/distribution.js.map +1 -0
- package/dist/queries/gov.d.ts +15 -0
- package/dist/queries/gov.d.ts.map +1 -0
- package/dist/queries/gov.js +98 -0
- package/dist/queries/gov.js.map +1 -0
- package/dist/queries/group.d.ts +15 -0
- package/dist/queries/group.d.ts.map +1 -0
- package/dist/queries/group.js +159 -0
- package/dist/queries/group.js.map +1 -0
- package/dist/queries/index.d.ts +10 -0
- package/dist/queries/index.js +10 -0
- package/dist/queries/sku.d.ts +16 -0
- package/dist/queries/sku.d.ts.map +1 -0
- package/dist/queries/sku.js +85 -0
- package/dist/queries/sku.js.map +1 -0
- package/dist/queries/staking.d.ts +15 -0
- package/dist/queries/staking.d.ts.map +1 -0
- package/dist/queries/staking.js +127 -0
- package/dist/queries/staking.js.map +1 -0
- package/dist/queries/utils.d.ts +54 -0
- package/dist/queries/utils.d.ts.map +1 -0
- package/dist/queries/utils.js +74 -0
- package/dist/queries/utils.js.map +1 -0
- package/dist/retry.d.ts +48 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +106 -0
- package/dist/retry.js.map +1 -0
- package/dist/server-utils.d.ts +61 -0
- package/dist/server-utils.d.ts.map +1 -0
- package/dist/server-utils.js +156 -0
- package/dist/server-utils.js.map +1 -0
- package/dist/tools/fundCredits.d.ts +8 -0
- package/dist/tools/fundCredits.d.ts.map +1 -0
- package/dist/tools/fundCredits.js +9 -0
- package/dist/tools/fundCredits.js.map +1 -0
- package/dist/tools/getBalance.d.ts +26 -0
- package/dist/tools/getBalance.d.ts.map +1 -0
- package/dist/tools/getBalance.js +59 -0
- package/dist/tools/getBalance.js.map +1 -0
- package/dist/tools/stopApp.d.ts +13 -0
- package/dist/tools/stopApp.d.ts.map +1 -0
- package/dist/tools/stopApp.js +15 -0
- package/dist/tools/stopApp.js.map +1 -0
- package/dist/transactions/bank.d.ts +11 -0
- package/dist/transactions/bank.d.ts.map +1 -0
- package/dist/transactions/bank.js +75 -0
- package/dist/transactions/bank.js.map +1 -0
- package/dist/transactions/billing.d.ts +11 -0
- package/dist/transactions/billing.d.ts.map +1 -0
- package/dist/transactions/billing.js +189 -0
- package/dist/transactions/billing.js.map +1 -0
- package/dist/transactions/distribution.d.ts +11 -0
- package/dist/transactions/distribution.d.ts.map +1 -0
- package/dist/transactions/distribution.js +60 -0
- package/dist/transactions/distribution.js.map +1 -0
- package/dist/transactions/gov.d.ts +11 -0
- package/dist/transactions/gov.d.ts.map +1 -0
- package/dist/transactions/gov.js +108 -0
- package/dist/transactions/gov.js.map +1 -0
- package/dist/transactions/group.d.ts +11 -0
- package/dist/transactions/group.d.ts.map +1 -0
- package/dist/transactions/group.js +347 -0
- package/dist/transactions/group.js.map +1 -0
- package/dist/transactions/index.d.ts +10 -0
- package/dist/transactions/index.js +10 -0
- package/dist/transactions/manifest.d.ts +11 -0
- package/dist/transactions/manifest.d.ts.map +1 -0
- package/dist/transactions/manifest.js +59 -0
- package/dist/transactions/manifest.js.map +1 -0
- package/dist/transactions/sku.d.ts +11 -0
- package/dist/transactions/sku.d.ts.map +1 -0
- package/dist/transactions/sku.js +191 -0
- package/dist/transactions/sku.js.map +1 -0
- package/dist/transactions/staking.d.ts +11 -0
- package/dist/transactions/staking.d.ts.map +1 -0
- package/dist/transactions/staking.js +79 -0
- package/dist/transactions/staking.js.map +1 -0
- package/dist/transactions/utils.d.ts +161 -0
- package/dist/transactions/utils.d.ts.map +1 -0
- package/dist/transactions/utils.js +272 -0
- package/dist/transactions/utils.js.map +1 -0
- package/dist/types.d.ts +390 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +45 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +53 -0
- package/dist/validation.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/wallet/index.d.ts +4 -0
- package/dist/wallet/index.js +3 -0
- package/dist/wallet/mnemonic.d.ts +47 -0
- package/dist/wallet/mnemonic.d.ts.map +1 -0
- package/dist/wallet/mnemonic.js +97 -0
- package/dist/wallet/mnemonic.js.map +1 -0
- package/dist/wallet/sign-arbitrary.d.ts +12 -0
- package/dist/wallet/sign-arbitrary.d.ts.map +1 -0
- package/dist/wallet/sign-arbitrary.js +36 -0
- package/dist/wallet/sign-arbitrary.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ManifestMCPConfig, SignArbitraryResult, WalletProvider } from "../types.js";
|
|
2
|
+
import { OfflineSigner } from "@cosmjs/proto-signing";
|
|
3
|
+
|
|
4
|
+
//#region src/wallet/mnemonic.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Mnemonic-based wallet provider for non-browser environments or testing
|
|
7
|
+
*
|
|
8
|
+
* SECURITY NOTE: The mnemonic is stored in memory until disconnect() is called.
|
|
9
|
+
* After disconnect(), the wallet cannot be reconnected - create a new instance instead.
|
|
10
|
+
*/
|
|
11
|
+
declare class MnemonicWalletProvider implements WalletProvider {
|
|
12
|
+
private config;
|
|
13
|
+
private mnemonic;
|
|
14
|
+
private wallet;
|
|
15
|
+
private aminoWallet;
|
|
16
|
+
private address;
|
|
17
|
+
private disconnected;
|
|
18
|
+
private initPromise;
|
|
19
|
+
constructor(config: ManifestMCPConfig, mnemonic: string);
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the wallet from the mnemonic
|
|
22
|
+
*/
|
|
23
|
+
private initWallet;
|
|
24
|
+
/**
|
|
25
|
+
* Connect (initialize) the wallet
|
|
26
|
+
*/
|
|
27
|
+
connect(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Disconnect and securely clear all sensitive data
|
|
30
|
+
*
|
|
31
|
+
* IMPORTANT: After calling disconnect(), this wallet instance cannot be reused.
|
|
32
|
+
* Create a new MnemonicWalletProvider instance if you need to reconnect.
|
|
33
|
+
*/
|
|
34
|
+
disconnect(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the wallet's address
|
|
37
|
+
*/
|
|
38
|
+
getAddress(): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Get the offline signer for signing transactions
|
|
41
|
+
*/
|
|
42
|
+
getSigner(): Promise<OfflineSigner>;
|
|
43
|
+
signArbitrary(address: string, data: string): Promise<SignArbitraryResult>;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { MnemonicWalletProvider };
|
|
47
|
+
//# sourceMappingURL=mnemonic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mnemonic.d.ts","names":[],"sources":["../../src/wallet/mnemonic.ts"],"mappings":";;;;;;AAoBA;;;;cAAa,sBAAA,YAAkC,cAAA;EAAA,QACrC,MAAA;EAAA,QACA,QAAA;EAAA,QACA,MAAA;EAAA,QACA,WAAA;EAAA,QACA,OAAA;EAAA,QACA,YAAA;EAAA,QAGA,WAAA;cAEI,MAAA,EAAQ,iBAAA,EAAmB,QAAA;EAXoB;;;EAAA,QAmB7C,UAAA;EAhBN;;;EAyFF,OAAA,CAAA,GAAW,OAAA;EAnFT;;;;;;EA6FF,UAAA,CAAA,GAAc,OAAA;EAVH;;;EAyBX,UAAA,CAAA,GAAc,OAAA;EAAA;;;EAgBd,SAAA,CAAA,GAAa,OAAA,CAAQ,aAAA;EAarB,aAAA,CACJ,OAAA,UACA,IAAA,WACC,OAAA,CAAQ,mBAAA;AAAA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ManifestMCPError, ManifestMCPErrorCode } from "../types.js";
|
|
2
|
+
import { signArbitraryWithAmino } from "./sign-arbitrary.js";
|
|
3
|
+
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
|
4
|
+
import { Secp256k1HdWallet } from "@cosmjs/amino";
|
|
5
|
+
//#region src/wallet/mnemonic.ts
|
|
6
|
+
/**
|
|
7
|
+
* Mnemonic-based wallet provider for non-browser environments or testing
|
|
8
|
+
*
|
|
9
|
+
* SECURITY NOTE: The mnemonic is stored in memory until disconnect() is called.
|
|
10
|
+
* After disconnect(), the wallet cannot be reconnected - create a new instance instead.
|
|
11
|
+
*/
|
|
12
|
+
var MnemonicWalletProvider = class {
|
|
13
|
+
constructor(config, mnemonic) {
|
|
14
|
+
this.wallet = null;
|
|
15
|
+
this.aminoWallet = null;
|
|
16
|
+
this.address = null;
|
|
17
|
+
this.disconnected = false;
|
|
18
|
+
this.initPromise = null;
|
|
19
|
+
this.config = config;
|
|
20
|
+
this.mnemonic = mnemonic;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Initialize the wallet from the mnemonic
|
|
24
|
+
*/
|
|
25
|
+
async initWallet() {
|
|
26
|
+
if (this.disconnected) throw new ManifestMCPError(ManifestMCPErrorCode.WALLET_NOT_CONNECTED, "Wallet has been disconnected and cannot be reconnected. Create a new MnemonicWalletProvider instance.");
|
|
27
|
+
if (this.wallet) return;
|
|
28
|
+
if (this.initPromise) return this.initPromise;
|
|
29
|
+
if (!this.mnemonic) throw new ManifestMCPError(ManifestMCPErrorCode.WALLET_NOT_CONNECTED, "Mnemonic has been cleared. Create a new MnemonicWalletProvider instance.");
|
|
30
|
+
const mnemonic = this.mnemonic;
|
|
31
|
+
this.initPromise = (async () => {
|
|
32
|
+
const prefix = this.config.addressPrefix ?? "manifest";
|
|
33
|
+
try {
|
|
34
|
+
this.wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix });
|
|
35
|
+
this.aminoWallet = await Secp256k1HdWallet.fromMnemonic(mnemonic, { prefix });
|
|
36
|
+
const accounts = await this.wallet.getAccounts();
|
|
37
|
+
if (accounts.length === 0) throw new ManifestMCPError(ManifestMCPErrorCode.INVALID_MNEMONIC, "No accounts derived from mnemonic");
|
|
38
|
+
this.address = accounts[0].address;
|
|
39
|
+
this.initPromise = null;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
this.initPromise = null;
|
|
42
|
+
this.wallet = null;
|
|
43
|
+
this.aminoWallet = null;
|
|
44
|
+
this.address = null;
|
|
45
|
+
if (error instanceof ManifestMCPError) throw error;
|
|
46
|
+
throw new ManifestMCPError(ManifestMCPErrorCode.INVALID_MNEMONIC, `Failed to create wallet from mnemonic: ${error instanceof Error ? error.message : String(error)}`);
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
return this.initPromise;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Connect (initialize) the wallet
|
|
53
|
+
*/
|
|
54
|
+
async connect() {
|
|
55
|
+
await this.initWallet();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Disconnect and securely clear all sensitive data
|
|
59
|
+
*
|
|
60
|
+
* IMPORTANT: After calling disconnect(), this wallet instance cannot be reused.
|
|
61
|
+
* Create a new MnemonicWalletProvider instance if you need to reconnect.
|
|
62
|
+
*/
|
|
63
|
+
async disconnect() {
|
|
64
|
+
this.mnemonic = null;
|
|
65
|
+
this.wallet = null;
|
|
66
|
+
this.aminoWallet = null;
|
|
67
|
+
this.address = null;
|
|
68
|
+
this.initPromise = null;
|
|
69
|
+
this.disconnected = true;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get the wallet's address
|
|
73
|
+
*/
|
|
74
|
+
async getAddress() {
|
|
75
|
+
await this.initWallet();
|
|
76
|
+
if (!this.address) throw new ManifestMCPError(ManifestMCPErrorCode.WALLET_NOT_CONNECTED, "Wallet failed to initialize");
|
|
77
|
+
return this.address;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the offline signer for signing transactions
|
|
81
|
+
*/
|
|
82
|
+
async getSigner() {
|
|
83
|
+
await this.initWallet();
|
|
84
|
+
if (!this.wallet) throw new ManifestMCPError(ManifestMCPErrorCode.WALLET_NOT_CONNECTED, "Wallet failed to initialize");
|
|
85
|
+
return this.wallet;
|
|
86
|
+
}
|
|
87
|
+
async signArbitrary(address, data) {
|
|
88
|
+
await this.initWallet();
|
|
89
|
+
if (!this.aminoWallet) throw new ManifestMCPError(ManifestMCPErrorCode.WALLET_NOT_CONNECTED, "Amino wallet failed to initialize");
|
|
90
|
+
if (!this.address) throw new ManifestMCPError(ManifestMCPErrorCode.WALLET_NOT_CONNECTED, "Wallet address not initialized");
|
|
91
|
+
return signArbitraryWithAmino(this.aminoWallet, this.address, address, data);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
export { MnemonicWalletProvider };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=mnemonic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mnemonic.js","names":[],"sources":["../../src/wallet/mnemonic.ts"],"sourcesContent":["import { Secp256k1HdWallet } from '@cosmjs/amino';\nimport {\n DirectSecp256k1HdWallet,\n type OfflineSigner,\n} from '@cosmjs/proto-signing';\nimport {\n type ManifestMCPConfig,\n ManifestMCPError,\n ManifestMCPErrorCode,\n type SignArbitraryResult,\n type WalletProvider,\n} from '../types.js';\nimport { signArbitraryWithAmino } from './sign-arbitrary.js';\n\n/**\n * Mnemonic-based wallet provider for non-browser environments or testing\n *\n * SECURITY NOTE: The mnemonic is stored in memory until disconnect() is called.\n * After disconnect(), the wallet cannot be reconnected - create a new instance instead.\n */\nexport class MnemonicWalletProvider implements WalletProvider {\n private config: ManifestMCPConfig;\n private mnemonic: string | null;\n private wallet: DirectSecp256k1HdWallet | null = null;\n private aminoWallet: Secp256k1HdWallet | null = null;\n private address: string | null = null;\n private disconnected: boolean = false;\n\n // Promise to prevent concurrent wallet initialization (lazy init race condition)\n private initPromise: Promise<void> | null = null;\n\n constructor(config: ManifestMCPConfig, mnemonic: string) {\n this.config = config;\n this.mnemonic = mnemonic;\n }\n\n /**\n * Initialize the wallet from the mnemonic\n */\n private async initWallet(): Promise<void> {\n if (this.disconnected) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.WALLET_NOT_CONNECTED,\n 'Wallet has been disconnected and cannot be reconnected. Create a new MnemonicWalletProvider instance.',\n );\n }\n\n // Return if already initialized\n if (this.wallet) {\n return;\n }\n\n // If initialization is already in progress, wait for it\n if (this.initPromise) {\n return this.initPromise;\n }\n\n if (!this.mnemonic) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.WALLET_NOT_CONNECTED,\n 'Mnemonic has been cleared. Create a new MnemonicWalletProvider instance.',\n );\n }\n\n // Capture mnemonic before the async IIFE so disconnect() cannot null it mid-flight\n const mnemonic = this.mnemonic;\n\n // Start initialization and cache the promise to prevent concurrent init\n this.initPromise = (async () => {\n const prefix = this.config.addressPrefix ?? 'manifest';\n\n try {\n this.wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {\n prefix,\n });\n this.aminoWallet = await Secp256k1HdWallet.fromMnemonic(mnemonic, {\n prefix,\n });\n\n const accounts = await this.wallet.getAccounts();\n if (accounts.length === 0) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_MNEMONIC,\n 'No accounts derived from mnemonic',\n );\n }\n\n this.address = accounts[0].address;\n // Clear promise after successful init - wallet check will short-circuit future calls\n this.initPromise = null;\n } catch (error) {\n // Clear state on failure so retry is possible\n this.initPromise = null;\n this.wallet = null;\n this.aminoWallet = null;\n this.address = null;\n if (error instanceof ManifestMCPError) {\n throw error;\n }\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_MNEMONIC,\n `Failed to create wallet from mnemonic: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n })();\n\n return this.initPromise;\n }\n\n /**\n * Connect (initialize) the wallet\n */\n async connect(): Promise<void> {\n await this.initWallet();\n }\n\n /**\n * Disconnect and securely clear all sensitive data\n *\n * IMPORTANT: After calling disconnect(), this wallet instance cannot be reused.\n * Create a new MnemonicWalletProvider instance if you need to reconnect.\n */\n async disconnect(): Promise<void> {\n // Clear the mnemonic by overwriting with empty string then nullifying\n // Note: JavaScript strings are immutable, so we can't truly zero the memory,\n // but we can remove all references to allow garbage collection\n this.mnemonic = null;\n this.wallet = null;\n this.aminoWallet = null;\n this.address = null;\n this.initPromise = null;\n this.disconnected = true;\n }\n\n /**\n * Get the wallet's address\n */\n async getAddress(): Promise<string> {\n await this.initWallet();\n\n if (!this.address) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.WALLET_NOT_CONNECTED,\n 'Wallet failed to initialize',\n );\n }\n\n return this.address;\n }\n\n /**\n * Get the offline signer for signing transactions\n */\n async getSigner(): Promise<OfflineSigner> {\n await this.initWallet();\n\n if (!this.wallet) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.WALLET_NOT_CONNECTED,\n 'Wallet failed to initialize',\n );\n }\n\n return this.wallet;\n }\n\n async signArbitrary(\n address: string,\n data: string,\n ): Promise<SignArbitraryResult> {\n await this.initWallet();\n\n if (!this.aminoWallet) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.WALLET_NOT_CONNECTED,\n 'Amino wallet failed to initialize',\n );\n }\n\n if (!this.address) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.WALLET_NOT_CONNECTED,\n 'Wallet address not initialized',\n );\n }\n return signArbitraryWithAmino(\n this.aminoWallet,\n this.address,\n address,\n data,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAoBA,IAAa,yBAAb,MAA8D;CAW5D,YAAY,QAA2B,UAAkB;AARzD,OAAQ,SAAyC;AACjD,OAAQ,cAAwC;AAChD,OAAQ,UAAyB;AACjC,OAAQ,eAAwB;AAGhC,OAAQ,cAAoC;AAG1C,OAAK,SAAS;AACd,OAAK,WAAW;;;;;CAMlB,MAAc,aAA4B;AACxC,MAAI,KAAK,aACP,OAAM,IAAI,iBACR,qBAAqB,sBACrB,wGACD;AAIH,MAAI,KAAK,OACP;AAIF,MAAI,KAAK,YACP,QAAO,KAAK;AAGd,MAAI,CAAC,KAAK,SACR,OAAM,IAAI,iBACR,qBAAqB,sBACrB,2EACD;EAIH,MAAM,WAAW,KAAK;AAGtB,OAAK,eAAe,YAAY;GAC9B,MAAM,SAAS,KAAK,OAAO,iBAAiB;AAE5C,OAAI;AACF,SAAK,SAAS,MAAM,wBAAwB,aAAa,UAAU,EACjE,QACD,CAAC;AACF,SAAK,cAAc,MAAM,kBAAkB,aAAa,UAAU,EAChE,QACD,CAAC;IAEF,MAAM,WAAW,MAAM,KAAK,OAAO,aAAa;AAChD,QAAI,SAAS,WAAW,EACtB,OAAM,IAAI,iBACR,qBAAqB,kBACrB,oCACD;AAGH,SAAK,UAAU,SAAS,GAAG;AAE3B,SAAK,cAAc;YACZ,OAAO;AAEd,SAAK,cAAc;AACnB,SAAK,SAAS;AACd,SAAK,cAAc;AACnB,SAAK,UAAU;AACf,QAAI,iBAAiB,iBACnB,OAAM;AAER,UAAM,IAAI,iBACR,qBAAqB,kBACrB,0CAA0C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GACjG;;MAED;AAEJ,SAAO,KAAK;;;;;CAMd,MAAM,UAAyB;AAC7B,QAAM,KAAK,YAAY;;;;;;;;CASzB,MAAM,aAA4B;AAIhC,OAAK,WAAW;AAChB,OAAK,SAAS;AACd,OAAK,cAAc;AACnB,OAAK,UAAU;AACf,OAAK,cAAc;AACnB,OAAK,eAAe;;;;;CAMtB,MAAM,aAA8B;AAClC,QAAM,KAAK,YAAY;AAEvB,MAAI,CAAC,KAAK,QACR,OAAM,IAAI,iBACR,qBAAqB,sBACrB,8BACD;AAGH,SAAO,KAAK;;;;;CAMd,MAAM,YAAoC;AACxC,QAAM,KAAK,YAAY;AAEvB,MAAI,CAAC,KAAK,OACR,OAAM,IAAI,iBACR,qBAAqB,sBACrB,8BACD;AAGH,SAAO,KAAK;;CAGd,MAAM,cACJ,SACA,MAC8B;AAC9B,QAAM,KAAK,YAAY;AAEvB,MAAI,CAAC,KAAK,YACR,OAAM,IAAI,iBACR,qBAAqB,sBACrB,oCACD;AAGH,MAAI,CAAC,KAAK,QACR,OAAM,IAAI,iBACR,qBAAqB,sBACrB,iCACD;AAEH,SAAO,uBACL,KAAK,aACL,KAAK,SACL,SACA,KACD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SignArbitraryResult } from "../types.js";
|
|
2
|
+
import { Secp256k1HdWallet } from "@cosmjs/amino";
|
|
3
|
+
|
|
4
|
+
//#region src/wallet/sign-arbitrary.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Sign arbitrary data using ADR-036 amino sign doc.
|
|
7
|
+
* Shared implementation used by both MnemonicWalletProvider and KeyfileWalletProvider.
|
|
8
|
+
*/
|
|
9
|
+
declare function signArbitraryWithAmino(aminoWallet: Secp256k1HdWallet, walletAddress: string, address: string, data: string): Promise<SignArbitraryResult>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { signArbitraryWithAmino };
|
|
12
|
+
//# sourceMappingURL=sign-arbitrary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-arbitrary.d.ts","names":[],"sources":["../../src/wallet/sign-arbitrary.ts"],"mappings":";;;;;;AAYA;;iBAAsB,sBAAA,CACpB,WAAA,EAAa,iBAAA,EACb,aAAA,UACA,OAAA,UACA,IAAA,WACC,OAAA,CAAQ,mBAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ManifestMCPError, ManifestMCPErrorCode } from "../types.js";
|
|
2
|
+
import { toBase64 } from "@cosmjs/encoding";
|
|
3
|
+
//#region src/wallet/sign-arbitrary.ts
|
|
4
|
+
/**
|
|
5
|
+
* Sign arbitrary data using ADR-036 amino sign doc.
|
|
6
|
+
* Shared implementation used by both MnemonicWalletProvider and KeyfileWalletProvider.
|
|
7
|
+
*/
|
|
8
|
+
async function signArbitraryWithAmino(aminoWallet, walletAddress, address, data) {
|
|
9
|
+
if (address !== walletAddress) throw new ManifestMCPError(ManifestMCPErrorCode.INVALID_ADDRESS, `Cannot sign for address "${address}": wallet address is "${walletAddress}"`);
|
|
10
|
+
const signDoc = {
|
|
11
|
+
chain_id: "",
|
|
12
|
+
account_number: "0",
|
|
13
|
+
sequence: "0",
|
|
14
|
+
fee: {
|
|
15
|
+
gas: "0",
|
|
16
|
+
amount: []
|
|
17
|
+
},
|
|
18
|
+
msgs: [{
|
|
19
|
+
type: "sign/MsgSignData",
|
|
20
|
+
value: {
|
|
21
|
+
signer: address,
|
|
22
|
+
data: toBase64(new TextEncoder().encode(data))
|
|
23
|
+
}
|
|
24
|
+
}],
|
|
25
|
+
memo: ""
|
|
26
|
+
};
|
|
27
|
+
const { signature } = await aminoWallet.signAmino(address, signDoc);
|
|
28
|
+
return {
|
|
29
|
+
pub_key: signature.pub_key,
|
|
30
|
+
signature: signature.signature
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { signArbitraryWithAmino };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=sign-arbitrary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-arbitrary.js","names":[],"sources":["../../src/wallet/sign-arbitrary.ts"],"sourcesContent":["import type { Secp256k1HdWallet } from '@cosmjs/amino';\nimport { toBase64 } from '@cosmjs/encoding';\nimport {\n ManifestMCPError,\n ManifestMCPErrorCode,\n type SignArbitraryResult,\n} from '../types.js';\n\n/**\n * Sign arbitrary data using ADR-036 amino sign doc.\n * Shared implementation used by both MnemonicWalletProvider and KeyfileWalletProvider.\n */\nexport async function signArbitraryWithAmino(\n aminoWallet: Secp256k1HdWallet,\n walletAddress: string,\n address: string,\n data: string,\n): Promise<SignArbitraryResult> {\n if (address !== walletAddress) {\n throw new ManifestMCPError(\n ManifestMCPErrorCode.INVALID_ADDRESS,\n `Cannot sign for address \"${address}\": wallet address is \"${walletAddress}\"`,\n );\n }\n\n const signDoc = {\n chain_id: '',\n account_number: '0',\n sequence: '0',\n fee: { gas: '0', amount: [] },\n msgs: [\n {\n type: 'sign/MsgSignData',\n value: {\n signer: address,\n data: toBase64(new TextEncoder().encode(data)),\n },\n },\n ],\n memo: '',\n };\n\n const { signature } = await aminoWallet.signAmino(address, signDoc);\n return {\n pub_key: signature.pub_key,\n signature: signature.signature,\n };\n}\n"],"mappings":";;;;;;;AAYA,eAAsB,uBACpB,aACA,eACA,SACA,MAC8B;AAC9B,KAAI,YAAY,cACd,OAAM,IAAI,iBACR,qBAAqB,iBACrB,4BAA4B,QAAQ,wBAAwB,cAAc,GAC3E;CAGH,MAAM,UAAU;EACd,UAAU;EACV,gBAAgB;EAChB,UAAU;EACV,KAAK;GAAE,KAAK;GAAK,QAAQ,EAAE;GAAE;EAC7B,MAAM,CACJ;GACE,MAAM;GACN,OAAO;IACL,QAAQ;IACR,MAAM,SAAS,IAAI,aAAa,CAAC,OAAO,KAAK,CAAC;IAC/C;GACF,CACF;EACD,MAAM;EACP;CAED,MAAM,EAAE,cAAc,MAAM,YAAY,UAAU,SAAS,QAAQ;AACnE,QAAO;EACL,SAAS,UAAU;EACnB,WAAW,UAAU;EACtB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@manifest-network/manifest-mcp-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared library for Cosmos SDK blockchain logic, tool functions, and server utilities (Manifest Network)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./__test-utils__/mocks.js": {
|
|
14
|
+
"import": "./dist/__test-utils__/mocks.js",
|
|
15
|
+
"types": "./dist/__test-utils__/mocks.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./__test-utils__/callTool.js": {
|
|
18
|
+
"import": "./dist/__test-utils__/callTool.js",
|
|
19
|
+
"types": "./dist/__test-utils__/callTool.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsdown",
|
|
24
|
+
"dev": "tsdown --watch",
|
|
25
|
+
"lint": "tsc --noEmit",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"mcp",
|
|
31
|
+
"cosmos",
|
|
32
|
+
"cosmjs",
|
|
33
|
+
"blockchain",
|
|
34
|
+
"manifest"
|
|
35
|
+
],
|
|
36
|
+
"author": "Felix C. Morency",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/manifest-network/manifest-mcp-mono.git",
|
|
41
|
+
"directory": "packages/core"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/manifest-network/manifest-mcp-mono#readme",
|
|
44
|
+
"bugs": "https://github.com/manifest-network/manifest-mcp-mono/issues",
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist"
|
|
53
|
+
],
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@cosmjs/amino": "0.32.4",
|
|
56
|
+
"@cosmjs/encoding": "0.32.4",
|
|
57
|
+
"@cosmjs/proto-signing": "0.32.4",
|
|
58
|
+
"@cosmjs/stargate": "npm:@manifest-network/stargate@0.32.4-ll.3",
|
|
59
|
+
"@manifest-network/manifestjs": "2.2.0-billing-v2.3",
|
|
60
|
+
"@modelcontextprotocol/sdk": "1.27.1",
|
|
61
|
+
"limiter": "3.0.0"
|
|
62
|
+
},
|
|
63
|
+
"overrides": {
|
|
64
|
+
"@cosmjs/stargate": "npm:@manifest-network/stargate@0.32.4-ll.3",
|
|
65
|
+
"axios": "1.13.2"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/node": "22.15.29",
|
|
69
|
+
"typescript": "5.9.3",
|
|
70
|
+
"vitest": "4.1.0"
|
|
71
|
+
}
|
|
72
|
+
}
|