@atxp/client 0.7.3 → 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 +20 -0
- package/dist/atxpAccount.d.ts.map +1 -0
- package/dist/atxpAccount.js +82 -19
- package/dist/atxpAccount.js.map +1 -1
- package/dist/atxpClient.d.ts +12 -0
- package/dist/atxpClient.d.ts.map +1 -0
- package/dist/atxpClient.js +18 -2
- package/dist/atxpClient.js.map +1 -1
- package/dist/atxpFetcher.d.ts +77 -0
- package/dist/atxpFetcher.d.ts.map +1 -0
- package/dist/atxpFetcher.js +95 -140
- package/dist/atxpFetcher.js.map +1 -1
- package/dist/atxpLocalAccount.d.ts +50 -0
- package/dist/atxpLocalAccount.d.ts.map +1 -0
- package/dist/baseAccount.d.ts +20 -0
- package/dist/baseAccount.d.ts.map +1 -0
- package/dist/baseAccount.js +15 -4
- package/dist/baseAccount.js.map +1 -1
- package/dist/baseConstants.d.ts +10 -0
- package/dist/baseConstants.d.ts.map +1 -0
- package/dist/basePaymentMaker.d.ts +23 -0
- package/dist/basePaymentMaker.d.ts.map +1 -0
- package/dist/basePaymentMaker.js +23 -3
- package/dist/basePaymentMaker.js.map +1 -1
- package/dist/clientTestHelpers.d.ts +6 -0
- package/dist/clientTestHelpers.d.ts.map +1 -0
- 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 +793 -454
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +111 -36
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +788 -456
- package/dist/index.js.map +1 -1
- package/dist/oAuth.d.ts +44 -0
- package/dist/oAuth.d.ts.map +1 -0
- 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/setup.expo.d.ts +2 -0
- package/dist/setup.expo.d.ts.map +1 -0
- package/dist/solanaAccount.d.ts +13 -0
- package/dist/solanaAccount.d.ts.map +1 -0
- package/dist/solanaAccount.js +16 -4
- package/dist/solanaAccount.js.map +1 -1
- package/dist/solanaPaymentMaker.d.ts +25 -0
- package/dist/solanaPaymentMaker.d.ts.map +1 -0
- package/dist/solanaPaymentMaker.js +27 -5
- package/dist/solanaPaymentMaker.js.map +1 -1
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js.map +1 -1
- package/dist/worldConstants.d.ts +53 -0
- package/dist/worldConstants.d.ts.map +1 -0
- 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,17 +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
|
-
}
|
|
80
69
|
|
|
81
70
|
type RequiredClientConfigFields = 'mcpServer' | 'account';
|
|
82
71
|
type OptionalClientConfig = Omit<ClientConfig, RequiredClientConfigFields>;
|
|
83
|
-
type BuildableClientConfigFields = 'oAuthDb' | 'logger';
|
|
72
|
+
type BuildableClientConfigFields = 'oAuthDb' | 'logger' | 'destinationMakers';
|
|
84
73
|
declare const DEFAULT_CLIENT_CONFIG: Required<Omit<OptionalClientConfig, BuildableClientConfigFields>>;
|
|
85
74
|
declare function buildClientConfig(args: ClientArgs): ClientConfig;
|
|
86
75
|
declare function buildStreamableTransport(args: ClientArgs): StreamableHTTPClientTransport;
|
|
@@ -142,11 +131,18 @@ declare class SolanaPaymentMaker implements PaymentMaker {
|
|
|
142
131
|
private source;
|
|
143
132
|
private logger;
|
|
144
133
|
constructor(solanaEndpoint: string, sourceSecretKey: string, logger?: Logger);
|
|
145
|
-
|
|
134
|
+
getSourceAddress(_params: {
|
|
135
|
+
amount: BigNumber$1;
|
|
136
|
+
currency: Currency;
|
|
137
|
+
receiver: string;
|
|
138
|
+
memo: string;
|
|
139
|
+
}): string;
|
|
140
|
+
generateJWT: ({ paymentRequestId, codeChallenge, accountId }: {
|
|
146
141
|
paymentRequestId: string;
|
|
147
142
|
codeChallenge: string;
|
|
143
|
+
accountId?: AccountId | null;
|
|
148
144
|
}) => Promise<string>;
|
|
149
|
-
makePayment: (
|
|
145
|
+
makePayment: (destinations: Destination[], memo: string, _paymentRequestId?: string) => Promise<PaymentIdentifier | null>;
|
|
150
146
|
}
|
|
151
147
|
|
|
152
148
|
type ExtendedWalletClient = WalletClient & PublicActions;
|
|
@@ -154,34 +150,46 @@ declare class BasePaymentMaker implements PaymentMaker {
|
|
|
154
150
|
protected signingClient: ExtendedWalletClient;
|
|
155
151
|
protected logger: Logger;
|
|
156
152
|
constructor(baseRPCUrl: string, walletClient: WalletClient, logger?: Logger);
|
|
157
|
-
|
|
153
|
+
getSourceAddress(_params: {
|
|
154
|
+
amount: BigNumber;
|
|
155
|
+
currency: Currency;
|
|
156
|
+
receiver: string;
|
|
157
|
+
memo: string;
|
|
158
|
+
}): string;
|
|
159
|
+
generateJWT({ paymentRequestId, codeChallenge, accountId }: {
|
|
158
160
|
paymentRequestId: string;
|
|
159
161
|
codeChallenge: string;
|
|
162
|
+
accountId?: AccountId | null;
|
|
160
163
|
}): Promise<string>;
|
|
161
|
-
makePayment(
|
|
164
|
+
makePayment(destinations: Destination[], _memo: string, _paymentRequestId?: string): Promise<PaymentIdentifier | null>;
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
declare class SolanaAccount implements Account {
|
|
165
|
-
accountId:
|
|
166
|
-
paymentMakers:
|
|
167
|
-
|
|
168
|
-
};
|
|
168
|
+
accountId: AccountId;
|
|
169
|
+
paymentMakers: PaymentMaker[];
|
|
170
|
+
private sourcePublicKey;
|
|
169
171
|
constructor(solanaEndpoint: string, sourceSecretKey: string);
|
|
172
|
+
/**
|
|
173
|
+
* Get sources for this account
|
|
174
|
+
*/
|
|
175
|
+
getSources(): Promise<Source[]>;
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
declare class ATXPAccount implements Account {
|
|
173
|
-
accountId:
|
|
174
|
-
paymentMakers:
|
|
175
|
-
[key: string]: PaymentMaker;
|
|
176
|
-
};
|
|
179
|
+
accountId: AccountId;
|
|
180
|
+
paymentMakers: PaymentMaker[];
|
|
177
181
|
origin: string;
|
|
178
182
|
token: string;
|
|
179
183
|
fetchFn: FetchLike;
|
|
184
|
+
private unqualifiedAccountId;
|
|
180
185
|
constructor(connectionString: string, opts?: {
|
|
181
186
|
fetchFn?: FetchLike;
|
|
182
|
-
network?: Network;
|
|
183
187
|
});
|
|
184
188
|
getSigner(): Promise<LocalAccount>;
|
|
189
|
+
/**
|
|
190
|
+
* Get sources for this account by calling the accounts service
|
|
191
|
+
*/
|
|
192
|
+
getSources(): Promise<Source[]>;
|
|
185
193
|
}
|
|
186
194
|
|
|
187
195
|
declare const USDC_CONTRACT_ADDRESS_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
@@ -247,11 +255,55 @@ declare const getWorldChainByChainId: (chainId: number) => WorldChain;
|
|
|
247
255
|
*/
|
|
248
256
|
declare const getWorldChainUSDCAddress: (chainId: number) => string;
|
|
249
257
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
+
};
|
|
254
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[];
|
|
255
307
|
private walletClient;
|
|
256
308
|
private account;
|
|
257
309
|
constructor(baseRPCUrl: string, sourceSecretKey: string);
|
|
@@ -260,6 +312,10 @@ declare class BaseAccount implements Account {
|
|
|
260
312
|
* This is only available for EVM-based accounts
|
|
261
313
|
*/
|
|
262
314
|
getSigner(): LocalAccount;
|
|
315
|
+
/**
|
|
316
|
+
* Get sources for this account
|
|
317
|
+
*/
|
|
318
|
+
getSources(): Promise<Source[]>;
|
|
263
319
|
}
|
|
264
320
|
|
|
265
321
|
/**
|
|
@@ -310,5 +366,24 @@ declare class ATXPLocalAccount implements LocalAccount {
|
|
|
310
366
|
readonly source: "custom";
|
|
311
367
|
}
|
|
312
368
|
|
|
313
|
-
|
|
314
|
-
|
|
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 };
|
|
@@ -0,0 +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,qCAAqC,EACrC,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,KAAK,GAAG,EACR,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC"}
|