@azeth/common 0.2.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/LICENSE +21 -0
- package/README.md +65 -0
- package/dist/abis/AzethAccount.d.ts +585 -0
- package/dist/abis/AzethAccount.d.ts.map +1 -0
- package/dist/abis/AzethAccount.js +760 -0
- package/dist/abis/AzethAccount.js.map +1 -0
- package/dist/abis/AzethFactory.d.ts +579 -0
- package/dist/abis/AzethFactory.d.ts.map +1 -0
- package/dist/abis/AzethFactory.js +747 -0
- package/dist/abis/AzethFactory.js.map +1 -0
- package/dist/abis/AzethOracle.d.ts +495 -0
- package/dist/abis/AzethOracle.d.ts.map +1 -0
- package/dist/abis/AzethOracle.js +643 -0
- package/dist/abis/AzethOracle.js.map +1 -0
- package/dist/abis/ERC8004ReputationRegistry.d.ts +319 -0
- package/dist/abis/ERC8004ReputationRegistry.d.ts.map +1 -0
- package/dist/abis/ERC8004ReputationRegistry.js +405 -0
- package/dist/abis/ERC8004ReputationRegistry.js.map +1 -0
- package/dist/abis/GuardianModule.d.ts +825 -0
- package/dist/abis/GuardianModule.d.ts.map +1 -0
- package/dist/abis/GuardianModule.js +1067 -0
- package/dist/abis/GuardianModule.js.map +1 -0
- package/dist/abis/PaymentAgreementModule.d.ts +716 -0
- package/dist/abis/PaymentAgreementModule.d.ts.map +1 -0
- package/dist/abis/PaymentAgreementModule.js +915 -0
- package/dist/abis/PaymentAgreementModule.js.map +1 -0
- package/dist/abis/ReputationModule.d.ts +837 -0
- package/dist/abis/ReputationModule.d.ts.map +1 -0
- package/dist/abis/ReputationModule.js +1080 -0
- package/dist/abis/ReputationModule.js.map +1 -0
- package/dist/abis/TrustRegistryModule.d.ts +238 -0
- package/dist/abis/TrustRegistryModule.d.ts.map +1 -0
- package/dist/abis/TrustRegistryModule.js +311 -0
- package/dist/abis/TrustRegistryModule.js.map +1 -0
- package/dist/abis/index.d.ts +9 -0
- package/dist/abis/index.d.ts.map +1 -0
- package/dist/abis/index.js +9 -0
- package/dist/abis/index.js.map +1 -0
- package/dist/constants/addresses.d.ts +52 -0
- package/dist/constants/addresses.d.ts.map +1 -0
- package/dist/constants/addresses.js +56 -0
- package/dist/constants/addresses.js.map +1 -0
- package/dist/constants/chains.d.ts +73 -0
- package/dist/constants/chains.d.ts.map +1 -0
- package/dist/constants/chains.js +66 -0
- package/dist/constants/chains.js.map +1 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +4 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/tokens.d.ts +19 -0
- package/dist/constants/tokens.d.ts.map +1 -0
- package/dist/constants/tokens.js +19 -0
- package/dist/constants/tokens.js.map +1 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/types/contracts.d.ts +34 -0
- package/dist/types/contracts.d.ts.map +1 -0
- package/dist/types/contracts.js +2 -0
- package/dist/types/contracts.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/messaging.d.ts +215 -0
- package/dist/types/messaging.d.ts.map +1 -0
- package/dist/types/messaging.js +3 -0
- package/dist/types/messaging.js.map +1 -0
- package/dist/types/participant.d.ts +23 -0
- package/dist/types/participant.d.ts.map +1 -0
- package/dist/types/participant.js +2 -0
- package/dist/types/participant.js.map +1 -0
- package/dist/types/payments.d.ts +35 -0
- package/dist/types/payments.d.ts.map +1 -0
- package/dist/types/payments.js +2 -0
- package/dist/types/payments.js.map +1 -0
- package/dist/types/registry.d.ts +84 -0
- package/dist/types/registry.d.ts.map +1 -0
- package/dist/types/registry.js +2 -0
- package/dist/types/registry.js.map +1 -0
- package/dist/types/reputation.d.ts +91 -0
- package/dist/types/reputation.d.ts.map +1 -0
- package/dist/types/reputation.js +2 -0
- package/dist/types/reputation.js.map +1 -0
- package/dist/utils/chains.d.ts +9 -0
- package/dist/utils/chains.d.ts.map +1 -0
- package/dist/utils/chains.js +19 -0
- package/dist/utils/chains.js.map +1 -0
- package/dist/utils/formatting.d.ts +11 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +69 -0
- package/dist/utils/formatting.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validation.d.ts +32 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +100 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/constants/addresses.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe;;0BAEiC,KAAK,MAAM,EAAE;iCACN,KAAK,MAAM,EAAE;sCACR,KAAK,MAAM,EAAE;yCACV,KAAK,MAAM,EAAE;mCACnB,KAAK,MAAM,EAAE;8BAClB,KAAK,MAAM,EAAE;wCACH,KAAK,MAAM,EAAE;;;0BAG3B,KAAK,MAAM,EAAE;iCACN,KAAK,MAAM,EAAE;sCACR,KAAK,MAAM,EAAE;yCACV,KAAK,MAAM,EAAE;mCACnB,KAAK,MAAM,EAAE;8BAClB,KAAK,MAAM,EAAE;wCACH,KAAK,MAAM,EAAE;;;0BAGrE,KAAK,MAAM,EAAE;iCACN,KAAK,MAAM,EAAE;sCACR,KAAK,MAAM,EAAE;yCACV,KAAK,MAAM,EAAE;mCACnB,KAAK,MAAM,EAAE;8BAClB,KAAK,MAAM,EAAE;wCACH,KAAK,MAAM,EAAE;;;0BAG3B,KAAK,MAAM,EAAE;iCACN,KAAK,MAAM,EAAE;sCACR,KAAK,MAAM,EAAE;yCACV,KAAK,MAAM,EAAE;mCACnB,KAAK,MAAM,EAAE;8BAClB,KAAK,MAAM,EAAE;wCACH,KAAK,MAAM,EAAE;;CAEpC,CAAC;AAGX,eAAO,MAAM,gBAAgB;mBAC2B,KAAK,MAAM,EAAE;uBACT,KAAK,MAAM,EAAE;0BACV,KAAK,MAAM,EAAE;8BACT,KAAK,MAAM,EAAE;CACtE,CAAC;AAGX,eAAO,MAAM,2BAA2B;mBACgB,KAAK,MAAM,EAAE;uBACT,KAAK,MAAM,EAAE;0BACV,KAAK,MAAM,EAAE;8BACT,KAAK,MAAM,EAAE;CACtE,CAAC;AAEX,eAAO,MAAM,cAAc,EAAmD,KAAK,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Contract addresses — auto-generated by scripts/sync-deployments.ts
|
|
2
|
+
// Do not edit manually. Run: pnpm sync:deployments
|
|
3
|
+
export const AZETH_CONTRACTS = {
|
|
4
|
+
baseSepolia: {
|
|
5
|
+
factory: '0x8B8cc09732cDF3e18EF441F70f88DfC0D11EeD3f',
|
|
6
|
+
guardianModule: '0xBC11De1fbA08D5d9294d1540A322dc1c8279CC3B',
|
|
7
|
+
trustRegistryModule: '0x106c2E84c00fdD32383cA315E43976aaA7930C03',
|
|
8
|
+
paymentAgreementModule: '0x566007ae53028b85699400CD437E011F5975cde9',
|
|
9
|
+
reputationModule: '0x0dC17903834b1cd704d3acb1f0c6f8A6529be2d5',
|
|
10
|
+
priceOracle: '0xFAeBC147a10F73669dD47a5CFC785f04aa47E696',
|
|
11
|
+
accountImplementation: '0x229dc447c874D19927da2B4B76dE97D8b3964Fcc',
|
|
12
|
+
},
|
|
13
|
+
ethereumSepolia: {
|
|
14
|
+
factory: '0x8B8cc09732cDF3e18EF441F70f88DfC0D11EeD3f',
|
|
15
|
+
guardianModule: '0xBC11De1fbA08D5d9294d1540A322dc1c8279CC3B',
|
|
16
|
+
trustRegistryModule: '0x106c2E84c00fdD32383cA315E43976aaA7930C03',
|
|
17
|
+
paymentAgreementModule: '0x566007ae53028b85699400CD437E011F5975cde9',
|
|
18
|
+
reputationModule: '0x0dC17903834b1cd704d3acb1f0c6f8A6529be2d5',
|
|
19
|
+
priceOracle: '0xFAeBC147a10F73669dD47a5CFC785f04aa47E696',
|
|
20
|
+
accountImplementation: '0x229dc447c874D19927da2B4B76dE97D8b3964Fcc',
|
|
21
|
+
},
|
|
22
|
+
base: {
|
|
23
|
+
factory: '',
|
|
24
|
+
guardianModule: '',
|
|
25
|
+
trustRegistryModule: '',
|
|
26
|
+
paymentAgreementModule: '',
|
|
27
|
+
reputationModule: '',
|
|
28
|
+
priceOracle: '',
|
|
29
|
+
accountImplementation: '',
|
|
30
|
+
},
|
|
31
|
+
ethereum: {
|
|
32
|
+
factory: '',
|
|
33
|
+
guardianModule: '',
|
|
34
|
+
trustRegistryModule: '',
|
|
35
|
+
paymentAgreementModule: '',
|
|
36
|
+
reputationModule: '',
|
|
37
|
+
priceOracle: '',
|
|
38
|
+
accountImplementation: '',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
// External contracts — ERC-8004 Identity Registry
|
|
42
|
+
export const ERC8004_REGISTRY = {
|
|
43
|
+
base: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
|
|
44
|
+
ethereum: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
|
|
45
|
+
baseSepolia: '0x8004A818BFB912233c491871b3d84c89A494BD9e',
|
|
46
|
+
ethereumSepolia: '0x8004A818BFB912233c491871b3d84c89A494BD9e',
|
|
47
|
+
};
|
|
48
|
+
// External contracts — ERC-8004 Reputation Registry
|
|
49
|
+
export const ERC8004_REPUTATION_REGISTRY = {
|
|
50
|
+
base: '0x8004BAa17C55a88189AE136b182e5fdA19dE9b63',
|
|
51
|
+
ethereum: '0x8004BAa17C55a88189AE136b182e5fdA19dE9b63',
|
|
52
|
+
baseSepolia: '0x8004B663056A597Dffe9eCcC1965A193B7388713',
|
|
53
|
+
ethereumSepolia: '0x8004B663056A597Dffe9eCcC1965A193B7388713',
|
|
54
|
+
};
|
|
55
|
+
export const ENTRYPOINT_V07 = '0x0000000071727De22E5E9d8BAf0edAc6f37da032';
|
|
56
|
+
//# sourceMappingURL=addresses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../src/constants/addresses.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mDAAmD;AAEnD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,WAAW,EAAE;QACX,OAAO,EAAE,4CAA6D;QACtE,cAAc,EAAE,4CAA6D;QAC7E,mBAAmB,EAAE,4CAA6D;QAClF,sBAAsB,EAAE,4CAA6D;QACrF,gBAAgB,EAAE,4CAA6D;QAC/E,WAAW,EAAE,4CAA6D;QAC1E,qBAAqB,EAAE,4CAA6D;KACrF;IACD,eAAe,EAAE;QACf,OAAO,EAAE,4CAA6D;QACtE,cAAc,EAAE,4CAA6D;QAC7E,mBAAmB,EAAE,4CAA6D;QAClF,sBAAsB,EAAE,4CAA6D;QACrF,gBAAgB,EAAE,4CAA6D;QAC/E,WAAW,EAAE,4CAA6D;QAC1E,qBAAqB,EAAE,4CAA6D;KACrF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,EAAmB;QAC5B,cAAc,EAAE,EAAmB;QACnC,mBAAmB,EAAE,EAAmB;QACxC,sBAAsB,EAAE,EAAmB;QAC3C,gBAAgB,EAAE,EAAmB;QACrC,WAAW,EAAE,EAAmB;QAChC,qBAAqB,EAAE,EAAmB;KAC3C;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,EAAmB;QAC5B,cAAc,EAAE,EAAmB;QACnC,mBAAmB,EAAE,EAAmB;QACxC,sBAAsB,EAAE,EAAmB;QAC3C,gBAAgB,EAAE,EAAmB;QACrC,WAAW,EAAE,EAAmB;QAChC,qBAAqB,EAAE,EAAmB;KAC3C;CACO,CAAC;AAEX,kDAAkD;AAClD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,4CAA6D;IACnE,QAAQ,EAAE,4CAA6D;IACvE,WAAW,EAAE,4CAA6D;IAC1E,eAAe,EAAE,4CAA6D;CACtE,CAAC;AAEX,oDAAoD;AACpD,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,4CAA6D;IACnE,QAAQ,EAAE,4CAA6D;IACvE,WAAW,EAAE,4CAA6D;IAC1E,eAAe,EAAE,4CAA6D;CACtE,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAG,4CAA6D,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** Per-chain infrastructure URLs and metadata.
|
|
2
|
+
*
|
|
3
|
+
* Resolution order for bundler/paymaster/RPC:
|
|
4
|
+
* 1. Explicit `AzethKitConfig` value
|
|
5
|
+
* 2. Environment variable (`AZETH_BUNDLER_URL`, `AZETH_PAYMASTER_URL`, `AZETH_RPC_URL`)
|
|
6
|
+
* 3. Chain default from this table (bundlerBaseUrl + PIMLICO_API_KEY from env)
|
|
7
|
+
* 4. Error with actionable setup instructions
|
|
8
|
+
*/
|
|
9
|
+
export interface ChainConfig {
|
|
10
|
+
readonly id: number;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
/** Default public RPC endpoint (always available) */
|
|
13
|
+
readonly rpcDefault: string;
|
|
14
|
+
/** Bundler base URL template — append `?apikey=<KEY>` at runtime.
|
|
15
|
+
* Undefined = no default template (must provide full URL via env/config). */
|
|
16
|
+
readonly bundlerBaseUrl?: string;
|
|
17
|
+
/** Paymaster base URL template — same pattern as bundlerBaseUrl. */
|
|
18
|
+
readonly paymasterBaseUrl?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const SUPPORTED_CHAINS: {
|
|
21
|
+
readonly base: {
|
|
22
|
+
readonly id: 8453;
|
|
23
|
+
readonly name: "Base";
|
|
24
|
+
readonly rpcDefault: "https://mainnet.base.org";
|
|
25
|
+
readonly bundlerBaseUrl: "https://api.pimlico.io/v2/8453/rpc";
|
|
26
|
+
};
|
|
27
|
+
readonly baseSepolia: {
|
|
28
|
+
readonly id: 84532;
|
|
29
|
+
readonly name: "Base Sepolia";
|
|
30
|
+
readonly rpcDefault: "https://sepolia.base.org";
|
|
31
|
+
readonly bundlerBaseUrl: "https://api.pimlico.io/v2/84532/rpc";
|
|
32
|
+
};
|
|
33
|
+
readonly ethereumSepolia: {
|
|
34
|
+
readonly id: 11155111;
|
|
35
|
+
readonly name: "Ethereum Sepolia";
|
|
36
|
+
readonly rpcDefault: "https://rpc.sepolia.org";
|
|
37
|
+
readonly bundlerBaseUrl: "https://api.pimlico.io/v2/11155111/rpc";
|
|
38
|
+
};
|
|
39
|
+
readonly ethereum: {
|
|
40
|
+
readonly id: 1;
|
|
41
|
+
readonly name: "Ethereum";
|
|
42
|
+
readonly rpcDefault: "https://cloudflare-eth.com";
|
|
43
|
+
readonly bundlerBaseUrl: "https://api.pimlico.io/v2/1/rpc";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type SupportedChainName = keyof typeof SUPPORTED_CHAINS;
|
|
47
|
+
/** Build a full bundler URL from the chain's base URL and an API key.
|
|
48
|
+
* Returns undefined if either is missing.
|
|
49
|
+
*
|
|
50
|
+
* @param chainName - Chain to look up (e.g. 'baseSepolia')
|
|
51
|
+
* @param apiKey - Pimlico API key (from PIMLICO_API_KEY env var)
|
|
52
|
+
*/
|
|
53
|
+
export declare function getBundlerUrl(chainName: SupportedChainName, apiKey?: string): string | undefined;
|
|
54
|
+
/** Build a full paymaster URL from the chain's base URL and an API key.
|
|
55
|
+
* Returns undefined if either is missing.
|
|
56
|
+
*
|
|
57
|
+
* Pimlico uses the same endpoint for both bundler and paymaster RPCs —
|
|
58
|
+
* the differentiation is at the RPC method level (`pm_sponsorUserOperation`
|
|
59
|
+
* vs `eth_sendUserOperation`), not the URL level.
|
|
60
|
+
*
|
|
61
|
+
* @param chainName - Chain to look up (e.g. 'baseSepolia')
|
|
62
|
+
* @param apiKey - Pimlico API key (from PIMLICO_API_KEY env var)
|
|
63
|
+
*/
|
|
64
|
+
/** Build the Azeth server bundler proxy URL from a server URL.
|
|
65
|
+
*
|
|
66
|
+
* Used as a fallback when no PIMLICO_API_KEY is available — the Azeth server
|
|
67
|
+
* proxies bundler requests using its own API key (testnet only).
|
|
68
|
+
*
|
|
69
|
+
* @param serverUrl - Azeth server URL (e.g. 'https://api.azeth.ai')
|
|
70
|
+
*/
|
|
71
|
+
export declare function getServerBundlerUrl(serverUrl: string): string;
|
|
72
|
+
export declare function getPaymasterUrl(chainName: SupportedChainName, apiKey?: string): string | undefined;
|
|
73
|
+
//# sourceMappingURL=chains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/constants/chains.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;kFAC8E;IAC9E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,oEAAoE;IACpE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBmB,CAAC;AAEjD,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIhG;AAED;;;;;;;;;GASG;AACH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKlG"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export const SUPPORTED_CHAINS = {
|
|
2
|
+
base: {
|
|
3
|
+
id: 8453,
|
|
4
|
+
name: 'Base',
|
|
5
|
+
rpcDefault: 'https://mainnet.base.org',
|
|
6
|
+
bundlerBaseUrl: 'https://api.pimlico.io/v2/8453/rpc',
|
|
7
|
+
},
|
|
8
|
+
baseSepolia: {
|
|
9
|
+
id: 84532,
|
|
10
|
+
name: 'Base Sepolia',
|
|
11
|
+
rpcDefault: 'https://sepolia.base.org',
|
|
12
|
+
bundlerBaseUrl: 'https://api.pimlico.io/v2/84532/rpc',
|
|
13
|
+
},
|
|
14
|
+
ethereumSepolia: {
|
|
15
|
+
id: 11155111,
|
|
16
|
+
name: 'Ethereum Sepolia',
|
|
17
|
+
rpcDefault: 'https://rpc.sepolia.org',
|
|
18
|
+
bundlerBaseUrl: 'https://api.pimlico.io/v2/11155111/rpc',
|
|
19
|
+
},
|
|
20
|
+
ethereum: {
|
|
21
|
+
id: 1,
|
|
22
|
+
name: 'Ethereum',
|
|
23
|
+
rpcDefault: 'https://cloudflare-eth.com',
|
|
24
|
+
bundlerBaseUrl: 'https://api.pimlico.io/v2/1/rpc',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
/** Build a full bundler URL from the chain's base URL and an API key.
|
|
28
|
+
* Returns undefined if either is missing.
|
|
29
|
+
*
|
|
30
|
+
* @param chainName - Chain to look up (e.g. 'baseSepolia')
|
|
31
|
+
* @param apiKey - Pimlico API key (from PIMLICO_API_KEY env var)
|
|
32
|
+
*/
|
|
33
|
+
export function getBundlerUrl(chainName, apiKey) {
|
|
34
|
+
const chain = SUPPORTED_CHAINS[chainName];
|
|
35
|
+
if (!chain?.bundlerBaseUrl || !apiKey)
|
|
36
|
+
return undefined;
|
|
37
|
+
return `${chain.bundlerBaseUrl}?apikey=${apiKey}`;
|
|
38
|
+
}
|
|
39
|
+
/** Build a full paymaster URL from the chain's base URL and an API key.
|
|
40
|
+
* Returns undefined if either is missing.
|
|
41
|
+
*
|
|
42
|
+
* Pimlico uses the same endpoint for both bundler and paymaster RPCs —
|
|
43
|
+
* the differentiation is at the RPC method level (`pm_sponsorUserOperation`
|
|
44
|
+
* vs `eth_sendUserOperation`), not the URL level.
|
|
45
|
+
*
|
|
46
|
+
* @param chainName - Chain to look up (e.g. 'baseSepolia')
|
|
47
|
+
* @param apiKey - Pimlico API key (from PIMLICO_API_KEY env var)
|
|
48
|
+
*/
|
|
49
|
+
/** Build the Azeth server bundler proxy URL from a server URL.
|
|
50
|
+
*
|
|
51
|
+
* Used as a fallback when no PIMLICO_API_KEY is available — the Azeth server
|
|
52
|
+
* proxies bundler requests using its own API key (testnet only).
|
|
53
|
+
*
|
|
54
|
+
* @param serverUrl - Azeth server URL (e.g. 'https://api.azeth.ai')
|
|
55
|
+
*/
|
|
56
|
+
export function getServerBundlerUrl(serverUrl) {
|
|
57
|
+
return `${serverUrl.replace(/\/$/, '')}/api/v1/bundler/rpc`;
|
|
58
|
+
}
|
|
59
|
+
export function getPaymasterUrl(chainName, apiKey) {
|
|
60
|
+
const chain = SUPPORTED_CHAINS[chainName];
|
|
61
|
+
if (!chain?.bundlerBaseUrl || !apiKey)
|
|
62
|
+
return undefined;
|
|
63
|
+
// Pimlico shares the same v2 endpoint for both bundler and paymaster
|
|
64
|
+
return `${chain.bundlerBaseUrl}?apikey=${apiKey}`;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=chains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/constants/chains.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE;QACJ,EAAE,EAAE,IAA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":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const TOKENS: {
|
|
2
|
+
readonly base: {
|
|
3
|
+
readonly USDC: `0x${string}`;
|
|
4
|
+
readonly WETH: `0x${string}`;
|
|
5
|
+
};
|
|
6
|
+
readonly baseSepolia: {
|
|
7
|
+
readonly USDC: `0x${string}`;
|
|
8
|
+
readonly WETH: `0x${string}`;
|
|
9
|
+
};
|
|
10
|
+
readonly ethereumSepolia: {
|
|
11
|
+
readonly USDC: `0x${string}`;
|
|
12
|
+
readonly WETH: `0x${string}`;
|
|
13
|
+
};
|
|
14
|
+
readonly ethereum: {
|
|
15
|
+
readonly USDC: `0x${string}`;
|
|
16
|
+
readonly WETH: `0x${string}`;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/constants/tokens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;uBAEuC,KAAK,MAAM,EAAE;uBACb,KAAK,MAAM,EAAE;;;uBAGb,KAAK,MAAM,EAAE;uBACb,KAAK,MAAM,EAAE;;;uBAGb,KAAK,MAAM,EAAE;uBACb,KAAK,MAAM,EAAE;;;uBAGb,KAAK,MAAM,EAAE;uBACb,KAAK,MAAM,EAAE;;CAE7D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const TOKENS = {
|
|
2
|
+
base: {
|
|
3
|
+
USDC: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
4
|
+
WETH: '0x4200000000000000000000000000000000000006',
|
|
5
|
+
},
|
|
6
|
+
baseSepolia: {
|
|
7
|
+
USDC: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
|
|
8
|
+
WETH: '0x4200000000000000000000000000000000000006',
|
|
9
|
+
},
|
|
10
|
+
ethereumSepolia: {
|
|
11
|
+
USDC: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',
|
|
12
|
+
WETH: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9',
|
|
13
|
+
},
|
|
14
|
+
ethereum: {
|
|
15
|
+
USDC: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
16
|
+
WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/constants/tokens.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE;QACJ,IAAI,EAAE,4CAA6D;QACnE,IAAI,EAAE,4CAA6D;KACpE;IACD,WAAW,EAAE;QACX,IAAI,EAAE,4CAA6D;QACnE,IAAI,EAAE,4CAA6D;KACpE;IACD,eAAe,EAAE;QACf,IAAI,EAAE,4CAA6D;QACnE,IAAI,EAAE,4CAA6D;KACpE;IACD,QAAQ,EAAE;QACR,IAAI,EAAE,4CAA6D;QACnE,IAAI,EAAE,4CAA6D;KACpE;CACO,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class AzethError extends Error {
|
|
2
|
+
readonly code: AzethErrorCode;
|
|
3
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
4
|
+
constructor(message: string, code: AzethErrorCode, details?: Record<string, unknown> | undefined);
|
|
5
|
+
}
|
|
6
|
+
export type AzethErrorCode = 'BUDGET_EXCEEDED' | 'GUARDIAN_REJECTED' | 'INSUFFICIENT_BALANCE' | 'SESSION_EXPIRED' | 'PAYMENT_FAILED' | 'SERVICE_NOT_FOUND' | 'REGISTRY_ERROR' | 'NETWORK_ERROR' | 'INVALID_INPUT' | 'UNAUTHORIZED' | 'INTERNAL_ERROR' | 'CONTRACT_ERROR' | 'ACCOUNT_NOT_FOUND' | 'ACCOUNT_EXISTS' | 'AGREEMENT_NOT_FOUND' | 'INSUFFICIENT_PAYMENT' | 'RECIPIENT_UNREACHABLE' | 'SERVER_UNAVAILABLE';
|
|
7
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAW,SAAQ,KAAK;aAGjB,IAAI,EAAE,cAAc;aACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFjD,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,cAAc,EACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAKpD;AAED,MAAM,MAAM,cAAc,GACtB,iBAAiB,GACjB,mBAAmB,GACnB,sBAAsB,GACtB,iBAAiB,GACjB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,eAAe,GACf,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,oBAAoB,CAAC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAGjB;IACA;IAHlB,YACE,OAAe,EACC,IAAoB,EACpB,OAAiC;QAEjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAgB;QACpB,YAAO,GAAP,OAAO,CAA0B;QAGjD,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,eAAO,MAAM,aAAa,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Resolved addresses for all Azeth protocol contracts on a given chain */
|
|
2
|
+
export interface AzethContractAddresses {
|
|
3
|
+
factory: `0x${string}`;
|
|
4
|
+
guardianModule: `0x${string}`;
|
|
5
|
+
trustRegistryModule: `0x${string}`;
|
|
6
|
+
paymentAgreementModule: `0x${string}`;
|
|
7
|
+
reputationModule: `0x${string}`;
|
|
8
|
+
priceOracle: `0x${string}`;
|
|
9
|
+
accountImplementation: `0x${string}`;
|
|
10
|
+
}
|
|
11
|
+
/** Per-token balance with USD value (mirrors IAzethOracle.TokenBalance with client-side labels) */
|
|
12
|
+
export interface TokenBalanceUSD {
|
|
13
|
+
token: `0x${string}`;
|
|
14
|
+
symbol: string;
|
|
15
|
+
balance: bigint;
|
|
16
|
+
balanceFormatted: string;
|
|
17
|
+
usdValue: bigint;
|
|
18
|
+
usdFormatted: string;
|
|
19
|
+
}
|
|
20
|
+
/** Aggregated balances for a single account with USD total */
|
|
21
|
+
export interface AccountBalanceUSD {
|
|
22
|
+
account: `0x${string}`;
|
|
23
|
+
label: string;
|
|
24
|
+
balances: TokenBalanceUSD[];
|
|
25
|
+
totalUSD: bigint;
|
|
26
|
+
totalUSDFormatted: string;
|
|
27
|
+
}
|
|
28
|
+
/** Result from getOwnerBalancesAndUSD — all accounts in one RPC call */
|
|
29
|
+
export interface AggregatedBalanceResult {
|
|
30
|
+
accounts: AccountBalanceUSD[];
|
|
31
|
+
grandTotalUSD: bigint;
|
|
32
|
+
grandTotalUSDFormatted: string;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/types/contracts.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,KAAK,MAAM,EAAE,CAAC;IAC9B,mBAAmB,EAAE,KAAK,MAAM,EAAE,CAAC;IACnC,sBAAsB,EAAE,KAAK,MAAM,EAAE,CAAC;IACtC,gBAAgB,EAAE,KAAK,MAAM,EAAE,CAAC;IAChC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,qBAAqB,EAAE,KAAK,MAAM,EAAE,CAAC;CACtC;AAED,mGAAmG;AACnG,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,KAAK,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,sBAAsB,EAAE,MAAM,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/types/contracts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
export interface XMTPMessage {
|
|
2
|
+
/** Sender identifier. May be an Ethereum address (0x-prefixed) or an XMTP InboxId.
|
|
3
|
+
* H-1 fix: Changed from `0x${string}` to `string` because XMTP InboxId is NOT
|
|
4
|
+
* a valid Ethereum address. Consumers must validate format before using as an address. */
|
|
5
|
+
sender: string;
|
|
6
|
+
content: string;
|
|
7
|
+
contentType: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
conversationId: string;
|
|
10
|
+
}
|
|
11
|
+
export type MessageHandler = (message: XMTPMessage) => Promise<void>;
|
|
12
|
+
/** Request to execute a service over XMTP */
|
|
13
|
+
export interface ServiceRequest {
|
|
14
|
+
type: 'service-request';
|
|
15
|
+
/** Unique request identifier for correlating responses */
|
|
16
|
+
id?: string;
|
|
17
|
+
/** Name of the service to invoke */
|
|
18
|
+
service: string;
|
|
19
|
+
/** Request payload passed to the service handler */
|
|
20
|
+
payload: Record<string, unknown>;
|
|
21
|
+
/** Optional payment information for paid services */
|
|
22
|
+
payment?: {
|
|
23
|
+
amount: string;
|
|
24
|
+
currency: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Inquiry about a service's details, pricing, or availability */
|
|
28
|
+
export interface ServiceInquiry {
|
|
29
|
+
type: 'service-inquiry';
|
|
30
|
+
/** Name of the service to inquire about */
|
|
31
|
+
service: string;
|
|
32
|
+
/** Optional question about the service */
|
|
33
|
+
question?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Response from a service execution */
|
|
36
|
+
export interface ServiceResponse {
|
|
37
|
+
type: 'service-response';
|
|
38
|
+
/** Correlating request ID */
|
|
39
|
+
requestId?: string;
|
|
40
|
+
/** Execution status */
|
|
41
|
+
status: 'success' | 'error' | 'payment-required';
|
|
42
|
+
/** Result data or error message */
|
|
43
|
+
result: unknown;
|
|
44
|
+
/** HTTP endpoint for paid service access via x402 */
|
|
45
|
+
httpEndpoint?: string;
|
|
46
|
+
/** Usage instructions */
|
|
47
|
+
usage?: unknown;
|
|
48
|
+
/** List of available service names (returned on unknown service errors) */
|
|
49
|
+
available?: string[];
|
|
50
|
+
}
|
|
51
|
+
/** Service metadata returned in capabilities or inquiry responses */
|
|
52
|
+
export interface ServiceDetail {
|
|
53
|
+
name: string;
|
|
54
|
+
description: string;
|
|
55
|
+
price: string | null;
|
|
56
|
+
method?: 'GET' | 'POST';
|
|
57
|
+
tags?: string[];
|
|
58
|
+
}
|
|
59
|
+
/** Advertised capabilities menu for service discovery over XMTP */
|
|
60
|
+
export interface CapabilitiesResponse {
|
|
61
|
+
type: 'capabilities';
|
|
62
|
+
/** Agent's Ethereum address */
|
|
63
|
+
agentAddress: `0x${string}`;
|
|
64
|
+
/** Human-readable agent name */
|
|
65
|
+
name: string;
|
|
66
|
+
/** All services offered by this agent */
|
|
67
|
+
services: ServiceDetail[];
|
|
68
|
+
/** Names of free (no payment required) services */
|
|
69
|
+
freeServices: string[];
|
|
70
|
+
/** Names of paid (x402 payment required) services */
|
|
71
|
+
paidServices: string[];
|
|
72
|
+
/** HTTP endpoint for x402-gated services */
|
|
73
|
+
httpEndpoint?: string;
|
|
74
|
+
/** Usage examples for free and paid services */
|
|
75
|
+
usage?: {
|
|
76
|
+
free: {
|
|
77
|
+
type: string;
|
|
78
|
+
service: string;
|
|
79
|
+
payload: Record<string, unknown>;
|
|
80
|
+
} | null;
|
|
81
|
+
paid: string | null;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Friend/connection request between agents */
|
|
85
|
+
export interface FriendRequest {
|
|
86
|
+
type: 'friend-request';
|
|
87
|
+
/** Requester's Ethereum address */
|
|
88
|
+
agentAddress: `0x${string}`;
|
|
89
|
+
/** Requester's display name */
|
|
90
|
+
name: string;
|
|
91
|
+
/** Requester's reputation score (optional) */
|
|
92
|
+
reputation?: number;
|
|
93
|
+
}
|
|
94
|
+
/** Acceptance of a friend/connection request */
|
|
95
|
+
export interface FriendAccept {
|
|
96
|
+
type: 'friend-accept';
|
|
97
|
+
/** Acceptor's Ethereum address */
|
|
98
|
+
agentAddress: `0x${string}`;
|
|
99
|
+
/** Acceptor's display name */
|
|
100
|
+
name: string;
|
|
101
|
+
}
|
|
102
|
+
/** Error response for failed operations */
|
|
103
|
+
export interface ErrorResponse {
|
|
104
|
+
type: 'error';
|
|
105
|
+
/** Human-readable error message */
|
|
106
|
+
error: string;
|
|
107
|
+
/** Machine-readable error code */
|
|
108
|
+
code?: string;
|
|
109
|
+
}
|
|
110
|
+
/** Acknowledgement response for received messages */
|
|
111
|
+
export interface AckResponse {
|
|
112
|
+
type: 'ack';
|
|
113
|
+
/** Type of message that was received */
|
|
114
|
+
received: string;
|
|
115
|
+
/** Optional note about the acknowledgement */
|
|
116
|
+
note?: string;
|
|
117
|
+
}
|
|
118
|
+
/** Detailed service information returned in response to a service-inquiry */
|
|
119
|
+
export interface ServiceDetailsResponse {
|
|
120
|
+
type: 'service-details';
|
|
121
|
+
/** Service name */
|
|
122
|
+
service: string;
|
|
123
|
+
/** Whether the service exists on this agent */
|
|
124
|
+
available: boolean;
|
|
125
|
+
/** Human-readable description (present when available=true) */
|
|
126
|
+
description?: string;
|
|
127
|
+
/** Price string or null for free services (present when available=true) */
|
|
128
|
+
price?: string | null;
|
|
129
|
+
/** HTTP method (present when available=true) */
|
|
130
|
+
method?: 'GET' | 'POST';
|
|
131
|
+
/** Whether the service requires payment (present when available=true) */
|
|
132
|
+
paid?: boolean;
|
|
133
|
+
/** Capability tags (present when available=true) */
|
|
134
|
+
capabilities?: string[];
|
|
135
|
+
/** HTTP endpoint for x402 access (present when available=true) */
|
|
136
|
+
httpEndpoint?: string;
|
|
137
|
+
/** Authentication method (present when available=true) */
|
|
138
|
+
authentication?: string;
|
|
139
|
+
/** Payment method (present when available=true) */
|
|
140
|
+
payment?: string;
|
|
141
|
+
/** List of all service names (present when available=false) */
|
|
142
|
+
allServices?: string[];
|
|
143
|
+
}
|
|
144
|
+
/** Union of all structured message types exchanged over XMTP */
|
|
145
|
+
export type StructuredMessage = ServiceRequest | ServiceInquiry | ServiceResponse | ServiceDetailsResponse | CapabilitiesResponse | FriendRequest | FriendAccept | ErrorResponse | AckResponse;
|
|
146
|
+
/** Handler function for executing a free service */
|
|
147
|
+
export type ServiceHandler = (sender: string, payload: Record<string, unknown>) => Promise<unknown>;
|
|
148
|
+
/** Definition of a skill/service offered by an agent */
|
|
149
|
+
export interface SkillDefinition {
|
|
150
|
+
/** Service name used for routing */
|
|
151
|
+
name: string;
|
|
152
|
+
/** Human-readable description */
|
|
153
|
+
description: string;
|
|
154
|
+
/** Price string (e.g., "$0.50") — null/undefined for free services */
|
|
155
|
+
price?: string;
|
|
156
|
+
/** HTTP method for paid service access */
|
|
157
|
+
method?: 'GET' | 'POST';
|
|
158
|
+
/** Categorization tags */
|
|
159
|
+
tags?: string[];
|
|
160
|
+
}
|
|
161
|
+
/** Configuration options for the MessageRouter */
|
|
162
|
+
export interface MessageRouterOptions {
|
|
163
|
+
/** Skills/services this agent offers */
|
|
164
|
+
skills: SkillDefinition[];
|
|
165
|
+
/** Human-readable agent name */
|
|
166
|
+
agentName: string;
|
|
167
|
+
/** Agent's Ethereum address */
|
|
168
|
+
agentAddress: `0x${string}`;
|
|
169
|
+
/** HTTP endpoint for x402-gated paid services */
|
|
170
|
+
httpEndpoint?: string;
|
|
171
|
+
/** Maximum messages per sender per minute (default 10) */
|
|
172
|
+
maxMessagesPerMinute?: number;
|
|
173
|
+
/** Minimum reputation score required to use services (default 30) */
|
|
174
|
+
minReputationForService?: number;
|
|
175
|
+
/** Async function to check a sender's reputation score */
|
|
176
|
+
reputationChecker?: (address: string) => Promise<number>;
|
|
177
|
+
/** Callback invoked when a friend request is received */
|
|
178
|
+
onFriendRequest?: (sender: string, req: FriendRequest) => Promise<void>;
|
|
179
|
+
/** Callback invoked when a friend accept is received */
|
|
180
|
+
onFriendAccept?: (sender: string, req: FriendAccept) => Promise<void>;
|
|
181
|
+
/** Fallback handler for plain text (non-JSON) messages. Return null to use default behavior. */
|
|
182
|
+
textFallbackHandler?: (sender: string, content: string) => Promise<string | null>;
|
|
183
|
+
}
|
|
184
|
+
export interface XMTPConfig {
|
|
185
|
+
/** XMTP environment */
|
|
186
|
+
env: 'production' | 'dev';
|
|
187
|
+
/** Path to store XMTP database files */
|
|
188
|
+
dbPath?: string;
|
|
189
|
+
/** 32-byte hex encryption key for the XMTP database (0x-prefixed) */
|
|
190
|
+
dbEncryptionKey?: string;
|
|
191
|
+
/** Rate limit: max messages per sender per minute (default 10) */
|
|
192
|
+
rateLimitPerMinute?: number;
|
|
193
|
+
/** Reachability cache TTL in milliseconds (default 300_000 = 5 min) */
|
|
194
|
+
reachabilityCacheTtlMs?: number;
|
|
195
|
+
/** Maximum message content length in bytes (default 10_000) */
|
|
196
|
+
maxMessageLength?: number;
|
|
197
|
+
/** Enable auto-reply via MessageRouter for incoming messages (default false) */
|
|
198
|
+
autoReply?: boolean;
|
|
199
|
+
}
|
|
200
|
+
export interface XMTPConversation {
|
|
201
|
+
id: string;
|
|
202
|
+
peerAddress: `0x${string}`;
|
|
203
|
+
createdAt: number;
|
|
204
|
+
lastMessageAt?: number;
|
|
205
|
+
lastMessagePreview?: string;
|
|
206
|
+
}
|
|
207
|
+
/** Context metadata attached to an incoming message for handler routing */
|
|
208
|
+
export interface MessageContext {
|
|
209
|
+
sender: `0x${string}`;
|
|
210
|
+
timestamp: number;
|
|
211
|
+
conversationId: string;
|
|
212
|
+
isStructured: boolean;
|
|
213
|
+
structuredType?: string;
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=messaging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../src/types/messaging.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B;;+FAE2F;IAC3F,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAIrE,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,iBAAiB,CAAC;IACxB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