@atxp/client 0.7.4 → 0.8.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/atxpAccount.d.ts +8 -6
- package/dist/atxpAccount.d.ts.map +1 -1
- package/dist/atxpAccount.js +57 -19
- package/dist/atxpAccount.js.map +1 -1
- package/dist/atxpClient.d.ts +1 -1
- package/dist/atxpClient.d.ts.map +1 -1
- package/dist/atxpClient.js +18 -2
- package/dist/atxpClient.js.map +1 -1
- package/dist/atxpFetcher.d.ts +5 -15
- package/dist/atxpFetcher.d.ts.map +1 -1
- package/dist/atxpFetcher.js +95 -229
- package/dist/atxpFetcher.js.map +1 -1
- package/dist/baseAccount.d.ts +7 -4
- package/dist/baseAccount.d.ts.map +1 -1
- package/dist/baseAccount.js +15 -4
- package/dist/baseAccount.js.map +1 -1
- package/dist/basePaymentMaker.d.ts +4 -3
- package/dist/basePaymentMaker.d.ts.map +1 -1
- package/dist/basePaymentMaker.js +20 -3
- package/dist/basePaymentMaker.js.map +1 -1
- package/dist/clientTestHelpers.d.ts.map +1 -1
- package/dist/destinationMakers/atxpDestinationMaker.d.ts +15 -0
- package/dist/destinationMakers/atxpDestinationMaker.d.ts.map +1 -0
- package/dist/destinationMakers/atxpDestinationMaker.js +128 -0
- package/dist/destinationMakers/atxpDestinationMaker.js.map +1 -0
- package/dist/destinationMakers/index.d.ts +9 -0
- package/dist/destinationMakers/index.d.ts.map +1 -0
- package/dist/destinationMakers/index.js +42 -0
- package/dist/destinationMakers/index.js.map +1 -0
- package/dist/destinationMakers/passthroughDestinationMaker.d.ts +8 -0
- package/dist/destinationMakers/passthroughDestinationMaker.d.ts.map +1 -0
- package/dist/destinationMakers/passthroughDestinationMaker.js +27 -0
- package/dist/destinationMakers/passthroughDestinationMaker.js.map +1 -0
- package/dist/index.cjs +803 -584
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +99 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +798 -586
- package/dist/index.js.map +1 -1
- package/dist/polygonConstants.d.ts +46 -0
- package/dist/polygonConstants.d.ts.map +1 -0
- package/dist/polygonConstants.js +54 -0
- package/dist/polygonConstants.js.map +1 -0
- package/dist/solanaAccount.d.ts +8 -4
- package/dist/solanaAccount.d.ts.map +1 -1
- package/dist/solanaAccount.js +16 -4
- package/dist/solanaAccount.js.map +1 -1
- package/dist/solanaPaymentMaker.d.ts +4 -3
- package/dist/solanaPaymentMaker.d.ts.map +1 -1
- package/dist/solanaPaymentMaker.js +24 -5
- package/dist/solanaPaymentMaker.js.map +1 -1
- package/dist/types.d.ts +5 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Account, Network, DestinationMaker, AuthorizationServerUrl, AccountId, Currency, OAuthDb, FetchLike, Logger, OAuthResourceClient, ClientCredentials, PKCEValues, AccessToken, PaymentMaker, Destination, PaymentIdentifier, Source, PaymentRequestOption } from '@atxp/common';
|
|
2
|
+
export { Account, PaymentMaker } from '@atxp/common';
|
|
2
3
|
import { ClientOptions, Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
3
4
|
import { Implementation } from '@modelcontextprotocol/sdk/types.js';
|
|
4
5
|
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
@@ -10,17 +11,10 @@ import { WalletClient, PublicActions, LocalAccount, Address, TypedData, Hex as H
|
|
|
10
11
|
type Hex = `0x${string}`;
|
|
11
12
|
type AccountPrefix = Network;
|
|
12
13
|
type AccountIdString = `${AccountPrefix}${string}`;
|
|
13
|
-
type Account = {
|
|
14
|
-
accountId: string;
|
|
15
|
-
paymentMakers: {
|
|
16
|
-
[key: string]: PaymentMaker;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
14
|
type ProspectivePayment = {
|
|
20
|
-
accountId:
|
|
15
|
+
accountId: AccountId;
|
|
21
16
|
resourceUrl: string;
|
|
22
17
|
resourceName: string;
|
|
23
|
-
network: Network;
|
|
24
18
|
currency: Currency;
|
|
25
19
|
amount: BigNumber;
|
|
26
20
|
iss: string;
|
|
@@ -28,6 +22,8 @@ type ProspectivePayment = {
|
|
|
28
22
|
type ClientConfig = {
|
|
29
23
|
mcpServer: string;
|
|
30
24
|
account: Account;
|
|
25
|
+
atxpAccountsServer: string;
|
|
26
|
+
destinationMakers: Map<Network, DestinationMaker>;
|
|
31
27
|
allowedAuthorizationServers: AuthorizationServerUrl[];
|
|
32
28
|
approvePayment: (payment: ProspectivePayment) => Promise<boolean>;
|
|
33
29
|
oAuthDb: OAuthDb;
|
|
@@ -70,23 +66,10 @@ declare class PaymentNetworkError extends Error {
|
|
|
70
66
|
readonly originalError?: Error | undefined;
|
|
71
67
|
constructor(message: string, originalError?: Error | undefined);
|
|
72
68
|
}
|
|
73
|
-
interface PaymentMaker {
|
|
74
|
-
makePayment: (amount: BigNumber, currency: Currency, receiver: string, memo: string) => Promise<string>;
|
|
75
|
-
generateJWT: (params: {
|
|
76
|
-
paymentRequestId: string;
|
|
77
|
-
codeChallenge: string;
|
|
78
|
-
}) => Promise<string>;
|
|
79
|
-
getSourceAddress: (params: {
|
|
80
|
-
amount: BigNumber;
|
|
81
|
-
currency: Currency;
|
|
82
|
-
receiver: string;
|
|
83
|
-
memo: string;
|
|
84
|
-
}) => string | Promise<string>;
|
|
85
|
-
}
|
|
86
69
|
|
|
87
70
|
type RequiredClientConfigFields = 'mcpServer' | 'account';
|
|
88
71
|
type OptionalClientConfig = Omit<ClientConfig, RequiredClientConfigFields>;
|
|
89
|
-
type BuildableClientConfigFields = 'oAuthDb' | 'logger';
|
|
72
|
+
type BuildableClientConfigFields = 'oAuthDb' | 'logger' | 'destinationMakers';
|
|
90
73
|
declare const DEFAULT_CLIENT_CONFIG: Required<Omit<OptionalClientConfig, BuildableClientConfigFields>>;
|
|
91
74
|
declare function buildClientConfig(args: ClientArgs): ClientConfig;
|
|
92
75
|
declare function buildStreamableTransport(args: ClientArgs): StreamableHTTPClientTransport;
|
|
@@ -154,11 +137,12 @@ declare class SolanaPaymentMaker implements PaymentMaker {
|
|
|
154
137
|
receiver: string;
|
|
155
138
|
memo: string;
|
|
156
139
|
}): string;
|
|
157
|
-
generateJWT: ({ paymentRequestId, codeChallenge }: {
|
|
140
|
+
generateJWT: ({ paymentRequestId, codeChallenge, accountId }: {
|
|
158
141
|
paymentRequestId: string;
|
|
159
142
|
codeChallenge: string;
|
|
143
|
+
accountId?: AccountId | null;
|
|
160
144
|
}) => Promise<string>;
|
|
161
|
-
makePayment: (
|
|
145
|
+
makePayment: (destinations: Destination[], memo: string, _paymentRequestId?: string) => Promise<PaymentIdentifier | null>;
|
|
162
146
|
}
|
|
163
147
|
|
|
164
148
|
type ExtendedWalletClient = WalletClient & PublicActions;
|
|
@@ -172,34 +156,40 @@ declare class BasePaymentMaker implements PaymentMaker {
|
|
|
172
156
|
receiver: string;
|
|
173
157
|
memo: string;
|
|
174
158
|
}): string;
|
|
175
|
-
generateJWT({ paymentRequestId, codeChallenge }: {
|
|
159
|
+
generateJWT({ paymentRequestId, codeChallenge, accountId }: {
|
|
176
160
|
paymentRequestId: string;
|
|
177
161
|
codeChallenge: string;
|
|
162
|
+
accountId?: AccountId | null;
|
|
178
163
|
}): Promise<string>;
|
|
179
|
-
makePayment(
|
|
164
|
+
makePayment(destinations: Destination[], _memo: string, _paymentRequestId?: string): Promise<PaymentIdentifier | null>;
|
|
180
165
|
}
|
|
181
166
|
|
|
182
167
|
declare class SolanaAccount implements Account {
|
|
183
|
-
accountId:
|
|
184
|
-
paymentMakers:
|
|
185
|
-
|
|
186
|
-
};
|
|
168
|
+
accountId: AccountId;
|
|
169
|
+
paymentMakers: PaymentMaker[];
|
|
170
|
+
private sourcePublicKey;
|
|
187
171
|
constructor(solanaEndpoint: string, sourceSecretKey: string);
|
|
172
|
+
/**
|
|
173
|
+
* Get sources for this account
|
|
174
|
+
*/
|
|
175
|
+
getSources(): Promise<Source[]>;
|
|
188
176
|
}
|
|
189
177
|
|
|
190
178
|
declare class ATXPAccount implements Account {
|
|
191
|
-
accountId:
|
|
192
|
-
paymentMakers:
|
|
193
|
-
[key: string]: PaymentMaker;
|
|
194
|
-
};
|
|
179
|
+
accountId: AccountId;
|
|
180
|
+
paymentMakers: PaymentMaker[];
|
|
195
181
|
origin: string;
|
|
196
182
|
token: string;
|
|
197
183
|
fetchFn: FetchLike;
|
|
184
|
+
private unqualifiedAccountId;
|
|
198
185
|
constructor(connectionString: string, opts?: {
|
|
199
186
|
fetchFn?: FetchLike;
|
|
200
|
-
network?: Network;
|
|
201
187
|
});
|
|
202
188
|
getSigner(): Promise<LocalAccount>;
|
|
189
|
+
/**
|
|
190
|
+
* Get sources for this account by calling the accounts service
|
|
191
|
+
*/
|
|
192
|
+
getSources(): Promise<Source[]>;
|
|
203
193
|
}
|
|
204
194
|
|
|
205
195
|
declare const USDC_CONTRACT_ADDRESS_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
@@ -265,11 +255,55 @@ declare const getWorldChainByChainId: (chainId: number) => WorldChain;
|
|
|
265
255
|
*/
|
|
266
256
|
declare const getWorldChainUSDCAddress: (chainId: number) => string;
|
|
267
257
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Polygon Chain configuration type, compatible with viem's Chain interface
|
|
260
|
+
*/
|
|
261
|
+
type PolygonChain = {
|
|
262
|
+
readonly id: number;
|
|
263
|
+
readonly name: string;
|
|
264
|
+
readonly nativeCurrency: {
|
|
265
|
+
readonly name: string;
|
|
266
|
+
readonly symbol: string;
|
|
267
|
+
readonly decimals: number;
|
|
268
|
+
};
|
|
269
|
+
readonly rpcUrls: {
|
|
270
|
+
readonly default: {
|
|
271
|
+
readonly http: readonly string[];
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
readonly blockExplorers: {
|
|
275
|
+
readonly default: {
|
|
276
|
+
readonly name: string;
|
|
277
|
+
readonly url: string;
|
|
278
|
+
};
|
|
272
279
|
};
|
|
280
|
+
readonly testnet?: boolean;
|
|
281
|
+
};
|
|
282
|
+
declare const USDC_CONTRACT_ADDRESS_POLYGON_MAINNET = "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359";
|
|
283
|
+
declare const POLYGON_MAINNET: PolygonChain;
|
|
284
|
+
/**
|
|
285
|
+
* Get Polygon Mainnet configuration with custom RPC URL (e.g., with API key)
|
|
286
|
+
* @param rpcUrl - Custom RPC URL, e.g., 'https://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEY'
|
|
287
|
+
*/
|
|
288
|
+
declare const getPolygonMainnetWithRPC: (rpcUrl: string) => PolygonChain;
|
|
289
|
+
/**
|
|
290
|
+
* Get Polygon Chain configuration by chain ID
|
|
291
|
+
* @param chainId - Chain ID (137 for mainnet)
|
|
292
|
+
* @returns Polygon Chain configuration
|
|
293
|
+
* @throws Error if chain ID is not supported
|
|
294
|
+
*/
|
|
295
|
+
declare const getPolygonByChainId: (chainId: number) => PolygonChain;
|
|
296
|
+
/**
|
|
297
|
+
* Get USDC contract address for Polygon by chain ID
|
|
298
|
+
* @param chainId - Chain ID (137 for mainnet)
|
|
299
|
+
* @returns USDC contract address
|
|
300
|
+
* @throws Error if chain ID is not supported
|
|
301
|
+
*/
|
|
302
|
+
declare const getPolygonUSDCAddress: (chainId: number) => string;
|
|
303
|
+
|
|
304
|
+
declare class BaseAccount implements Account {
|
|
305
|
+
accountId: AccountId;
|
|
306
|
+
paymentMakers: PaymentMaker[];
|
|
273
307
|
private walletClient;
|
|
274
308
|
private account;
|
|
275
309
|
constructor(baseRPCUrl: string, sourceSecretKey: string);
|
|
@@ -278,6 +312,10 @@ declare class BaseAccount implements Account {
|
|
|
278
312
|
* This is only available for EVM-based accounts
|
|
279
313
|
*/
|
|
280
314
|
getSigner(): LocalAccount;
|
|
315
|
+
/**
|
|
316
|
+
* Get sources for this account
|
|
317
|
+
*/
|
|
318
|
+
getSources(): Promise<Source[]>;
|
|
281
319
|
}
|
|
282
320
|
|
|
283
321
|
/**
|
|
@@ -328,5 +366,24 @@ declare class ATXPLocalAccount implements LocalAccount {
|
|
|
328
366
|
readonly source: "custom";
|
|
329
367
|
}
|
|
330
368
|
|
|
331
|
-
|
|
332
|
-
|
|
369
|
+
/**
|
|
370
|
+
* Destination mapper for ATXP network destinations.
|
|
371
|
+
* Converts destinations with network='atxp' to actual blockchain network destinations
|
|
372
|
+
* by resolving the account ID to its associated blockchain addresses.
|
|
373
|
+
*/
|
|
374
|
+
declare class ATXPDestinationMaker implements DestinationMaker {
|
|
375
|
+
private accountsServiceUrl;
|
|
376
|
+
private fetchFn;
|
|
377
|
+
constructor(accountsServiceUrl: string, fetchFn?: FetchLike);
|
|
378
|
+
makeDestinations(option: PaymentRequestOption, logger: Logger, paymentRequestId: string, sources: Source[]): Promise<Destination[]>;
|
|
379
|
+
private getDestinations;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
declare class PassthroughDestinationMaker implements DestinationMaker {
|
|
383
|
+
private network;
|
|
384
|
+
constructor(network: Network);
|
|
385
|
+
makeDestinations(option: PaymentRequestOption, _logger: Logger, _paymentRequestId: string, _sources: Source[]): Promise<Destination[]>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export { ATXPAccount, ATXPDestinationMaker, ATXPLocalAccount, BaseAccount, BasePaymentMaker, DEFAULT_CLIENT_CONFIG, InsufficientFundsError, OAuthAuthenticationRequiredError, OAuthClient, POLYGON_MAINNET, PassthroughDestinationMaker, PaymentNetworkError, SolanaAccount, SolanaPaymentMaker, USDC_CONTRACT_ADDRESS_BASE, USDC_CONTRACT_ADDRESS_BASE_SEPOLIA, USDC_CONTRACT_ADDRESS_POLYGON_MAINNET, USDC_CONTRACT_ADDRESS_WORLD_MAINNET, USDC_CONTRACT_ADDRESS_WORLD_SEPOLIA, ValidateTransferError, WORLD_CHAIN_MAINNET, WORLD_CHAIN_SEPOLIA, atxpClient, atxpFetch, buildClientConfig, buildStreamableTransport, getBaseUSDCAddress, getPolygonByChainId, getPolygonMainnetWithRPC, getPolygonUSDCAddress, getWorldChainByChainId, getWorldChainMainnetWithRPC, getWorldChainSepoliaWithRPC, getWorldChainUSDCAddress };
|
|
389
|
+
export type { AccountIdString, ClientArgs, ClientConfig, FetchWrapper, Hex, OAuthClientConfig, PolygonChain, ProspectivePayment, WorldChain };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,UAAU,EACX,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,gCAAgC,EAChC,KAAK,iBAAiB,EACtB,WAAW,EACZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,SAAS,EACV,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,aAAa,EACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,0BAA0B,EAC1B,kCAAkC,EAClC,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,mCAAmC,EACnC,mCAAmC,EACnC,mBAAmB,EACnB,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,KAAK,GAAG,EACR,KAAK,eAAe,EACpB,KAA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