@atxp/client 0.8.0 → 0.8.1
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/atxpClient.d.ts.map +1 -1
- package/dist/atxpClient.js +1 -2
- package/dist/atxpClient.js.map +1 -1
- package/dist/baseAccount.d.ts +3 -3
- package/dist/baseAccount.d.ts.map +1 -1
- package/dist/baseAccount.js +3 -4
- package/dist/baseAccount.js.map +1 -1
- package/dist/destinationMakers/index.d.ts.map +1 -1
- package/dist/destinationMakers/index.js +3 -0
- package/dist/destinationMakers/index.js.map +1 -1
- package/dist/index.cjs +149 -268
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +144 -268
- package/dist/index.js.map +1 -1
- package/dist/polygonConstants.d.ts +9 -2
- package/dist/polygonConstants.d.ts.map +1 -1
- package/dist/polygonConstants.js +36 -6
- package/dist/polygonConstants.js.map +1 -1
- package/package.json +2 -2
- package/dist/atxpAccount.d.ts +0 -20
- package/dist/atxpAccount.d.ts.map +0 -1
- package/dist/atxpAccount.js +0 -161
- package/dist/atxpAccount.js.map +0 -1
package/dist/atxpClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atxpClient.d.ts","sourceRoot":"","sources":["../src/atxpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGtD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"atxpClient.d.ts","sourceRoot":"","sources":["../src/atxpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGtD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAInG,KAAK,0BAA0B,GAAG,WAAW,GAAG,SAAS,CAAC;AAC1D,KAAK,oBAAoB,GAAG,IAAI,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;AAC3E,KAAK,2BAA2B,GAAG,SAAS,GAAG,QAAQ,GAAG,mBAAmB,CAAC;AAY9E,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,2BAA2B,CAAC,CAkBnG,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY,CA8BhE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,UAAU,GAAG,6BAA6B,CAQxF;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlE"}
|
package/dist/atxpClient.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { DEFAULT_ATXP_ACCOUNTS_SERVER, DEFAULT_AUTHORIZATION_SERVER, ConsoleLogger, MemoryOAuthDb } from '@atxp/common';
|
|
1
|
+
import { DEFAULT_ATXP_ACCOUNTS_SERVER, DEFAULT_AUTHORIZATION_SERVER, ConsoleLogger, MemoryOAuthDb, ATXPAccount } from '@atxp/common';
|
|
2
2
|
import { atxpFetch } from './atxpFetcher.js';
|
|
3
3
|
import { Client } from './node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js';
|
|
4
4
|
import { StreamableHTTPClientTransport } from './node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js';
|
|
5
5
|
import { createDestinationMakers } from './destinationMakers/index.js';
|
|
6
|
-
import { ATXPAccount } from './atxpAccount.js';
|
|
7
6
|
|
|
8
7
|
// Detect if we're in a browser environment and bind fetch appropriately
|
|
9
8
|
const getFetch = () => {
|
package/dist/atxpClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atxpClient.js","sources":["../src/atxpClient.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"atxpClient.js","sources":["../src/atxpClient.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAYA;AACA,MAAM,QAAQ,GAAG,MAAmB;AAClC,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,EAAE;;AAEvE,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;IAC3B;;AAEA,IAAA,OAAO,KAAK;AACd,CAAC;AAEM,MAAM,qBAAqB,GAAsE;IACtG,2BAA2B,EAAE,CAAC,4BAA4B,CAAC;AAC3D,IAAA,kBAAkB,EAAE,4BAA4B;AAChD,IAAA,cAAc,EAAE,OAAO,EAAE,KAAK,IAAI;IAClC,OAAO,EAAE,QAAQ,EAAE;IACnB,iBAAiB,EAAE,QAAQ,EAAE;IAC7B,SAAS,EAAE,KAAK;AAChB,IAAA,UAAU,EAAE;AACV,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,OAAO,EAAE;AACV,KAAA;AACD,IAAA,aAAa,EAAE;AACb,QAAA,YAAY,EAAE;AACf,KAAA;AACD,IAAA,WAAW,EAAE,cAAa,CAAC;AAC3B,IAAA,kBAAkB,EAAE,cAAa,CAAC;AAClC,IAAA,SAAS,EAAE,cAAa,CAAC;AACzB,IAAA,gBAAgB,EAAE,cAAa;;AAG3B,SAAU,iBAAiB,CAAC,IAAgB,EAAA;;IAEhD,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;AAC3C,QAAA,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,OAAO;IACvC;;AAEA,IAAA,MAAM,WAAW,GAAG;AAClB,QAAA,GAAG,qBAAqB;AACxB,QAAA,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa;KAClD;IACD,MAAM,YAAY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wBAAwB,CAAC,MAAM,CAAC;AAElD,IAAA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC;AAClE,IAAA,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;AAE/B,IAAA,OAAO,MAAM;AACf;;;;"}
|
package/dist/baseAccount.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ export declare class BaseAccount implements Account {
|
|
|
8
8
|
private account;
|
|
9
9
|
constructor(baseRPCUrl: string, sourceSecretKey: string);
|
|
10
10
|
/**
|
|
11
|
-
* Get
|
|
12
|
-
* This
|
|
11
|
+
* Get the LocalAccount (signer) for this account.
|
|
12
|
+
* This can be used with the x402 library or other signing operations.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
getLocalAccount(): LocalAccount;
|
|
15
15
|
/**
|
|
16
16
|
* Get sources for this account
|
|
17
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseAccount.d.ts","sourceRoot":"","sources":["../src/baseAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAO,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,EAA0C,YAAY,EAAE,MAAM,MAAM,CAAC;AAG5E,qBAAa,WAAY,YAAW,OAAO;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,OAAO,CAAoB;gBAEvB,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM;IAsBvD;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"baseAccount.d.ts","sourceRoot":"","sources":["../src/baseAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAO,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,EAA0C,YAAY,EAAE,MAAM,MAAM,CAAC;AAG5E,qBAAa,WAAY,YAAW,OAAO;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,OAAO,CAAoB;gBAEvB,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM;IAsBvD;;;OAGG;IACH,eAAe,IAAI,YAAY;IAI/B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAOtC"}
|
package/dist/baseAccount.js
CHANGED
|
@@ -24,11 +24,10 @@ class BaseAccount {
|
|
|
24
24
|
];
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Get
|
|
28
|
-
* This
|
|
27
|
+
* Get the LocalAccount (signer) for this account.
|
|
28
|
+
* This can be used with the x402 library or other signing operations.
|
|
29
29
|
*/
|
|
30
|
-
|
|
31
|
-
// Return the viem account directly - it implements LocalAccount interface
|
|
30
|
+
getLocalAccount() {
|
|
32
31
|
return this.account;
|
|
33
32
|
}
|
|
34
33
|
/**
|
package/dist/baseAccount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseAccount.js","sources":["../src/baseAccount.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;MAOa,WAAW,CAAA;IAMtB,WAAA,CAAY,UAAkB,EAAE,eAAuB,EAAA;QACrD,IAAI,CAAC,UAAU,EAAE;AACf,YAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;QAC7C;QACA,IAAI,CAAC,eAAe,EAAE;AACpB,YAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC;QAClD;AAEA,QAAA,IAAI,CAAC,OAAO,GAAG,mBAAmB,CAAC,eAAsB,C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ACrB;AAEA;;AAEG;AACH,IAAA,MAAM,UAAU,GAAA;AACd,QAAA,OAAO,CAAC;AACN,gBAAA,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;AAC7B,gBAAA,KAAK,EAAE,MAAM;AACb,gBAAA,UAAU,EAAE;AACb,aAAA,CAAC;IACJ;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/destinationMakers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,gBAAgB,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAI9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,WAAW,6BAA6B;IAC5C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,6BAA6B,GAAG,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/destinationMakers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,gBAAgB,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAI9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,WAAW,6BAA6B;IAC5C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,6BAA6B,GAAG,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAwC7G"}
|
|
@@ -27,6 +27,9 @@ function createDestinationMakers(config) {
|
|
|
27
27
|
case NetworkEnum.WorldSepolia:
|
|
28
28
|
makers.set(network, new PassthroughDestinationMaker(network));
|
|
29
29
|
break;
|
|
30
|
+
case NetworkEnum.PolygonAmoy:
|
|
31
|
+
makers.set(network, new PassthroughDestinationMaker(network));
|
|
32
|
+
break;
|
|
30
33
|
case NetworkEnum.ATXP:
|
|
31
34
|
makers.set(network, new ATXPDestinationMaker(atxpAccountsServer, fetchFn));
|
|
32
35
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/destinationMakers/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAYM,SAAU,uBAAuB,CAAC,MAAqC,EAAA;IAC3E,MAAM,EAAE,kBAAkB,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,MAAM;;AAGtD,IAAA,MAAM,MAAM,GAAG,IAAI,GAAG,EAA6B;IAEnD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;;QAEhD,QAAQ,OAAO;YACb,KAAK,WAAW,CAAC,MAAM;gBACrB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;gBAC7D;YACF,KAAK,WAAW,CAAC,IAAI;gBACnB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;gBAC7D;YACF,KAAK,WAAW,CAAC,KAAK;gBACpB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;gBAC7D;YACF,KAAK,WAAW,CAAC,OAAO;gBACtB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;gBAC7D;YACF,KAAK,WAAW,CAAC,WAAW;gBAC1B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;gBAC7D;YACF,KA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AAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;gBAC7D;YACF,KAAK,WAAW,CAAC,YAAY;gBAC3B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;gBAC7D;YACF,KAAK,WAAW,CAAC,WAAW;gBAC1B,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;gBAC7D;YACF,KAAK,WAAW,CAAC,IAAI;AACnB,gBAAA,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,oBAAoB,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;gBAC1E;AACF,YAAA;;gBAEE,WAAW,CAAC,OAAO,CAAC;;IAE1B;AAEA,IAAA,OAAO,MAAM;AACf;;;;"}
|
package/dist/index.cjs
CHANGED
|
@@ -15991,6 +15991,9 @@ function createDestinationMakers(config) {
|
|
|
15991
15991
|
case common.NetworkEnum.WorldSepolia:
|
|
15992
15992
|
makers.set(network, new PassthroughDestinationMaker(network));
|
|
15993
15993
|
break;
|
|
15994
|
+
case common.NetworkEnum.PolygonAmoy:
|
|
15995
|
+
makers.set(network, new PassthroughDestinationMaker(network));
|
|
15996
|
+
break;
|
|
15994
15997
|
case common.NetworkEnum.ATXP:
|
|
15995
15998
|
makers.set(network, new ATXPDestinationMaker(atxpAccountsServer, fetchFn));
|
|
15996
15999
|
break;
|
|
@@ -16002,263 +16005,6 @@ function createDestinationMakers(config) {
|
|
|
16002
16005
|
return makers;
|
|
16003
16006
|
}
|
|
16004
16007
|
|
|
16005
|
-
function toBasicAuth$1(token) {
|
|
16006
|
-
// Basic auth is base64("username:password"), password is blank
|
|
16007
|
-
const b64 = Buffer.from(`${token}:`).toString('base64');
|
|
16008
|
-
return `Basic ${b64}`;
|
|
16009
|
-
}
|
|
16010
|
-
/**
|
|
16011
|
-
* ATXP implementation of viem's LocalAccount interface.
|
|
16012
|
-
* Delegates signing operations to the accounts-x402 API.
|
|
16013
|
-
* Includes properties needed by x402 library for wallet client compatibility.
|
|
16014
|
-
*/
|
|
16015
|
-
class ATXPLocalAccount {
|
|
16016
|
-
constructor(address, origin, token, fetchFn = fetch) {
|
|
16017
|
-
this.address = address;
|
|
16018
|
-
this.origin = origin;
|
|
16019
|
-
this.token = token;
|
|
16020
|
-
this.fetchFn = fetchFn;
|
|
16021
|
-
this.type = 'local';
|
|
16022
|
-
/**
|
|
16023
|
-
* Get public key - required by LocalAccount interface
|
|
16024
|
-
*/
|
|
16025
|
-
this.publicKey = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
16026
|
-
/**
|
|
16027
|
-
* Source - required by LocalAccount interface (set to 'custom')
|
|
16028
|
-
*/
|
|
16029
|
-
this.source = 'custom';
|
|
16030
|
-
// x402 library expects these properties for wallet client compatibility
|
|
16031
|
-
this.account = this; // Self-reference for x402's isSignerWallet check
|
|
16032
|
-
this.chain = { id: 8453 }; // Base mainnet - could make this configurable
|
|
16033
|
-
this.transport = {}; // Empty transport object for x402 compatibility
|
|
16034
|
-
}
|
|
16035
|
-
/**
|
|
16036
|
-
* Fetch the wallet address from the /address endpoint
|
|
16037
|
-
*/
|
|
16038
|
-
static async create(origin, token, fetchFn = fetch) {
|
|
16039
|
-
// The /address endpoint uses Basic auth like other authenticated endpoints
|
|
16040
|
-
// For X402, we need the Ethereum/Base address with USDC currency
|
|
16041
|
-
const url = new URL(`${origin}/address`);
|
|
16042
|
-
url.searchParams.set('network', 'base'); // X402 operates on Base
|
|
16043
|
-
url.searchParams.set('currency', 'USDC'); // Always USDC for X402
|
|
16044
|
-
const response = await fetchFn(url.toString(), {
|
|
16045
|
-
method: 'GET',
|
|
16046
|
-
headers: {
|
|
16047
|
-
'Authorization': toBasicAuth$1(token)
|
|
16048
|
-
}
|
|
16049
|
-
});
|
|
16050
|
-
if (!response.ok) {
|
|
16051
|
-
const errorText = await response.text();
|
|
16052
|
-
throw new Error(`Failed to fetch destination address: ${response.status} ${response.statusText} ${errorText}`);
|
|
16053
|
-
}
|
|
16054
|
-
const data = await response.json();
|
|
16055
|
-
const address = data.address;
|
|
16056
|
-
if (!address) {
|
|
16057
|
-
throw new Error('Address endpoint did not return an address');
|
|
16058
|
-
}
|
|
16059
|
-
// Check that the account is an Ethereum/Base account (required for X402/EVM operations)
|
|
16060
|
-
const network = data.network;
|
|
16061
|
-
if (!network) {
|
|
16062
|
-
throw new Error('Address endpoint did not return a network');
|
|
16063
|
-
}
|
|
16064
|
-
if (network !== 'ethereum' && network !== 'base') {
|
|
16065
|
-
throw new Error(`ATXPLocalAccount requires an Ethereum/Base account, but got ${network} account`);
|
|
16066
|
-
}
|
|
16067
|
-
return new ATXPLocalAccount(address, origin, token, fetchFn);
|
|
16068
|
-
}
|
|
16069
|
-
/**
|
|
16070
|
-
* Sign a typed data structure using EIP-712
|
|
16071
|
-
* This is what x402 library will call for EIP-3009 authorization
|
|
16072
|
-
*/
|
|
16073
|
-
async signTypedData(typedData) {
|
|
16074
|
-
const response = await this.fetchFn(`${this.origin}/sign-typed-data`, {
|
|
16075
|
-
method: 'POST',
|
|
16076
|
-
headers: {
|
|
16077
|
-
'Authorization': toBasicAuth$1(this.token),
|
|
16078
|
-
'Content-Type': 'application/json',
|
|
16079
|
-
},
|
|
16080
|
-
body: JSON.stringify({
|
|
16081
|
-
typedData
|
|
16082
|
-
})
|
|
16083
|
-
});
|
|
16084
|
-
if (!response.ok) {
|
|
16085
|
-
const errorText = await response.text();
|
|
16086
|
-
throw new Error(`Failed to sign typed data: ${response.status} ${response.statusText} ${errorText}`);
|
|
16087
|
-
}
|
|
16088
|
-
const result = await response.json();
|
|
16089
|
-
return result.signature;
|
|
16090
|
-
}
|
|
16091
|
-
/**
|
|
16092
|
-
* Sign a message - required by LocalAccount interface but not used for X402
|
|
16093
|
-
*/
|
|
16094
|
-
async signMessage(_) {
|
|
16095
|
-
throw new Error('Message signing not implemented for ATXP local account');
|
|
16096
|
-
}
|
|
16097
|
-
/**
|
|
16098
|
-
* Sign a transaction - required by LocalAccount interface but not used for X402
|
|
16099
|
-
*/
|
|
16100
|
-
async signTransaction(_transaction, _args) {
|
|
16101
|
-
throw new Error('Transaction signing not implemented for ATXP local account');
|
|
16102
|
-
}
|
|
16103
|
-
}
|
|
16104
|
-
|
|
16105
|
-
function toBasicAuth(token) {
|
|
16106
|
-
// Basic auth is base64("username:password"), password is blank
|
|
16107
|
-
const b64 = Buffer.from(`${token}:`).toString('base64');
|
|
16108
|
-
return `Basic ${b64}`;
|
|
16109
|
-
}
|
|
16110
|
-
function parseConnectionString(connectionString) {
|
|
16111
|
-
const url = new URL(connectionString);
|
|
16112
|
-
const origin = url.origin;
|
|
16113
|
-
const token = url.searchParams.get('connection_token') || '';
|
|
16114
|
-
const accountId = url.searchParams.get('account_id');
|
|
16115
|
-
if (!token) {
|
|
16116
|
-
throw new Error('ATXPAccount: connection string missing connection token');
|
|
16117
|
-
}
|
|
16118
|
-
if (!accountId) {
|
|
16119
|
-
throw new Error('ATXPAccount: connection string missing account id');
|
|
16120
|
-
}
|
|
16121
|
-
return { origin, token, accountId };
|
|
16122
|
-
}
|
|
16123
|
-
class ATXPHttpPaymentMaker {
|
|
16124
|
-
constructor(origin, token, fetchFn = fetch) {
|
|
16125
|
-
this.origin = origin;
|
|
16126
|
-
this.token = token;
|
|
16127
|
-
this.fetchFn = fetchFn;
|
|
16128
|
-
}
|
|
16129
|
-
async getSourceAddress(params) {
|
|
16130
|
-
// Call the /address_for_payment endpoint to get the source address for this account
|
|
16131
|
-
const response = await this.fetchFn(`${this.origin}/address_for_payment`, {
|
|
16132
|
-
method: 'POST',
|
|
16133
|
-
headers: {
|
|
16134
|
-
'Authorization': toBasicAuth(this.token),
|
|
16135
|
-
'Content-Type': 'application/json',
|
|
16136
|
-
},
|
|
16137
|
-
body: JSON.stringify({
|
|
16138
|
-
amount: params.amount.toString(),
|
|
16139
|
-
currency: params.currency,
|
|
16140
|
-
receiver: params.receiver,
|
|
16141
|
-
memo: params.memo,
|
|
16142
|
-
}),
|
|
16143
|
-
});
|
|
16144
|
-
if (!response.ok) {
|
|
16145
|
-
const text = await response.text();
|
|
16146
|
-
throw new Error(`ATXPAccount: /address_for_payment failed: ${response.status} ${response.statusText} ${text}`);
|
|
16147
|
-
}
|
|
16148
|
-
const json = await response.json();
|
|
16149
|
-
if (!json?.sourceAddress) {
|
|
16150
|
-
throw new Error('ATXPAccount: /address_for_payment did not return sourceAddress');
|
|
16151
|
-
}
|
|
16152
|
-
return json.sourceAddress;
|
|
16153
|
-
}
|
|
16154
|
-
async makePayment(destinations, memo, paymentRequestId) {
|
|
16155
|
-
// Make a payment via the /pay endpoint with multiple destinations
|
|
16156
|
-
const response = await this.fetchFn(`${this.origin}/pay`, {
|
|
16157
|
-
method: 'POST',
|
|
16158
|
-
headers: {
|
|
16159
|
-
'Authorization': toBasicAuth(this.token),
|
|
16160
|
-
'Content-Type': 'application/json',
|
|
16161
|
-
},
|
|
16162
|
-
body: JSON.stringify({
|
|
16163
|
-
destinations: destinations.map(d => ({
|
|
16164
|
-
chain: d.chain,
|
|
16165
|
-
address: d.address,
|
|
16166
|
-
amount: d.amount.toString(),
|
|
16167
|
-
currency: d.currency
|
|
16168
|
-
})),
|
|
16169
|
-
memo,
|
|
16170
|
-
...(paymentRequestId && { paymentRequestId })
|
|
16171
|
-
}),
|
|
16172
|
-
});
|
|
16173
|
-
if (!response.ok) {
|
|
16174
|
-
const text = await response.text();
|
|
16175
|
-
throw new Error(`ATXPAccount: /pay failed: ${response.status} ${response.statusText} ${text}`);
|
|
16176
|
-
}
|
|
16177
|
-
const json = await response.json();
|
|
16178
|
-
const transactionId = json.transactionId;
|
|
16179
|
-
if (!transactionId) {
|
|
16180
|
-
throw new Error('ATXPAccount: /pay did not return transactionId or txHash');
|
|
16181
|
-
}
|
|
16182
|
-
if (!json?.chain) {
|
|
16183
|
-
throw new Error('ATXPAccount: /pay did not return chain');
|
|
16184
|
-
}
|
|
16185
|
-
if (!json?.currency) {
|
|
16186
|
-
throw new Error('ATXPAccount: /pay did not return currency');
|
|
16187
|
-
}
|
|
16188
|
-
return {
|
|
16189
|
-
transactionId,
|
|
16190
|
-
...(json.transactionSubId ? { transactionSubId: json.transactionSubId } : {}),
|
|
16191
|
-
chain: json.chain,
|
|
16192
|
-
currency: json.currency
|
|
16193
|
-
};
|
|
16194
|
-
}
|
|
16195
|
-
async generateJWT(params) {
|
|
16196
|
-
const response = await this.fetchFn(`${this.origin}/sign`, {
|
|
16197
|
-
method: 'POST',
|
|
16198
|
-
headers: {
|
|
16199
|
-
'Authorization': toBasicAuth(this.token),
|
|
16200
|
-
'Content-Type': 'application/json',
|
|
16201
|
-
},
|
|
16202
|
-
body: JSON.stringify({
|
|
16203
|
-
paymentRequestId: params.paymentRequestId,
|
|
16204
|
-
codeChallenge: params.codeChallenge,
|
|
16205
|
-
...(params.accountId ? { accountId: params.accountId } : {}),
|
|
16206
|
-
}),
|
|
16207
|
-
});
|
|
16208
|
-
if (!response.ok) {
|
|
16209
|
-
const text = await response.text();
|
|
16210
|
-
throw new Error(`ATXPAccount: /sign failed: ${response.status} ${response.statusText} ${text}`);
|
|
16211
|
-
}
|
|
16212
|
-
const json = await response.json();
|
|
16213
|
-
if (!json?.jwt) {
|
|
16214
|
-
throw new Error('ATXPAccount: /sign did not return jwt');
|
|
16215
|
-
}
|
|
16216
|
-
return json.jwt;
|
|
16217
|
-
}
|
|
16218
|
-
}
|
|
16219
|
-
class ATXPAccount {
|
|
16220
|
-
constructor(connectionString, opts) {
|
|
16221
|
-
const { origin, token, accountId } = parseConnectionString(connectionString);
|
|
16222
|
-
const fetchFn = opts?.fetchFn ?? fetch;
|
|
16223
|
-
// Store for use in X402 payment creation
|
|
16224
|
-
this.origin = origin;
|
|
16225
|
-
this.token = token;
|
|
16226
|
-
this.fetchFn = fetchFn;
|
|
16227
|
-
// Format accountId as network:address
|
|
16228
|
-
// Connection string provides just the atxp_acct_xxx part (no prefix for UI)
|
|
16229
|
-
this.unqualifiedAccountId = accountId;
|
|
16230
|
-
this.accountId = `atxp:${accountId}`;
|
|
16231
|
-
this.paymentMakers = [
|
|
16232
|
-
new ATXPHttpPaymentMaker(origin, token, fetchFn)
|
|
16233
|
-
];
|
|
16234
|
-
}
|
|
16235
|
-
async getSigner() {
|
|
16236
|
-
return ATXPLocalAccount.create(this.origin, this.token, this.fetchFn);
|
|
16237
|
-
}
|
|
16238
|
-
/**
|
|
16239
|
-
* Get sources for this account by calling the accounts service
|
|
16240
|
-
*/
|
|
16241
|
-
async getSources() {
|
|
16242
|
-
// Use the unqualified account ID (without atxp: prefix) for the API call
|
|
16243
|
-
const response = await this.fetchFn(`${this.origin}/account/${this.unqualifiedAccountId}/sources`, {
|
|
16244
|
-
method: 'GET',
|
|
16245
|
-
headers: {
|
|
16246
|
-
'Accept': 'application/json',
|
|
16247
|
-
}
|
|
16248
|
-
});
|
|
16249
|
-
if (!response.ok) {
|
|
16250
|
-
const text = await response.text();
|
|
16251
|
-
throw new Error(`ATXPAccount: /account/${this.unqualifiedAccountId}/sources failed: ${response.status} ${response.statusText} ${text}`);
|
|
16252
|
-
}
|
|
16253
|
-
const json = await response.json();
|
|
16254
|
-
// The accounts service returns the sources array directly, not wrapped in an object
|
|
16255
|
-
if (!Array.isArray(json)) {
|
|
16256
|
-
throw new Error(`ATXPAccount: /account/${this.unqualifiedAccountId}/sources did not return sources array`);
|
|
16257
|
-
}
|
|
16258
|
-
return json;
|
|
16259
|
-
}
|
|
16260
|
-
}
|
|
16261
|
-
|
|
16262
16008
|
// Detect if we're in a browser environment and bind fetch appropriately
|
|
16263
16009
|
const getFetch = () => {
|
|
16264
16010
|
if (typeof window !== 'undefined' && typeof window.fetch === 'function') {
|
|
@@ -16306,7 +16052,7 @@ function buildClientConfig(args) {
|
|
|
16306
16052
|
// QoL hack for unspecified accounts server - if the caller is passing an atxpAccount, then assume the origin for that
|
|
16307
16053
|
// is what we should use for the accounts server. In practice, the only option is accounts.atxp.ai,
|
|
16308
16054
|
// but this supports staging environment
|
|
16309
|
-
if (args.atxpAccountsServer === undefined && withDefaults.account && withDefaults.account instanceof ATXPAccount) {
|
|
16055
|
+
if (args.atxpAccountsServer === undefined && withDefaults.account && withDefaults.account instanceof common.ATXPAccount) {
|
|
16310
16056
|
accountsServer = withDefaults.account.origin;
|
|
16311
16057
|
}
|
|
16312
16058
|
const destinationMakers = withDefaults.destinationMakers ?? createDestinationMakers({
|
|
@@ -16716,11 +16462,13 @@ const getWorldChainUSDCAddress = (chainId) => {
|
|
|
16716
16462
|
};
|
|
16717
16463
|
|
|
16718
16464
|
const USDC_CONTRACT_ADDRESS_POLYGON_MAINNET = "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"; // Native USDC on Polygon mainnet
|
|
16465
|
+
const USDC_CONTRACT_ADDRESS_POLYGON_AMOY = "0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582"; // USDC on Polygon Amoy testnet
|
|
16719
16466
|
// Polygon Mainnet (Chain ID: 137)
|
|
16467
|
+
// Note: Native currency upgraded from MATIC to POL on September 4, 2024
|
|
16720
16468
|
const POLYGON_MAINNET = {
|
|
16721
16469
|
id: 137,
|
|
16722
16470
|
name: 'Polygon',
|
|
16723
|
-
nativeCurrency: { name: '
|
|
16471
|
+
nativeCurrency: { name: 'POL', symbol: 'POL', decimals: 18 },
|
|
16724
16472
|
rpcUrls: {
|
|
16725
16473
|
default: { http: ['https://polygon-rpc.com'] }
|
|
16726
16474
|
},
|
|
@@ -16728,6 +16476,20 @@ const POLYGON_MAINNET = {
|
|
|
16728
16476
|
default: { name: 'PolygonScan', url: 'https://polygonscan.com' }
|
|
16729
16477
|
}
|
|
16730
16478
|
};
|
|
16479
|
+
// Polygon Amoy Testnet (Chain ID: 80002)
|
|
16480
|
+
// Note: Amoy testnet also uses POL as native currency (following mainnet upgrade)
|
|
16481
|
+
const POLYGON_AMOY = {
|
|
16482
|
+
id: 80002,
|
|
16483
|
+
name: 'Polygon Amoy',
|
|
16484
|
+
nativeCurrency: { name: 'POL', symbol: 'POL', decimals: 18 },
|
|
16485
|
+
rpcUrls: {
|
|
16486
|
+
default: { http: ['https://rpc-amoy.polygon.technology'] }
|
|
16487
|
+
},
|
|
16488
|
+
blockExplorers: {
|
|
16489
|
+
default: { name: 'PolygonScan Amoy', url: 'https://amoy.polygonscan.com' }
|
|
16490
|
+
},
|
|
16491
|
+
testnet: true
|
|
16492
|
+
};
|
|
16731
16493
|
/**
|
|
16732
16494
|
* Get Polygon Mainnet configuration with custom RPC URL (e.g., with API key)
|
|
16733
16495
|
* @param rpcUrl - Custom RPC URL, e.g., 'https://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEY'
|
|
@@ -16738,9 +16500,19 @@ const getPolygonMainnetWithRPC = (rpcUrl) => ({
|
|
|
16738
16500
|
default: { http: [rpcUrl] }
|
|
16739
16501
|
}
|
|
16740
16502
|
});
|
|
16503
|
+
/**
|
|
16504
|
+
* Get Polygon Amoy Testnet configuration with custom RPC URL (e.g., with API key)
|
|
16505
|
+
* @param rpcUrl - Custom RPC URL, e.g., 'https://polygon-amoy.g.alchemy.com/v2/YOUR_API_KEY'
|
|
16506
|
+
*/
|
|
16507
|
+
const getPolygonAmoyWithRPC = (rpcUrl) => ({
|
|
16508
|
+
...POLYGON_AMOY,
|
|
16509
|
+
rpcUrls: {
|
|
16510
|
+
default: { http: [rpcUrl] }
|
|
16511
|
+
}
|
|
16512
|
+
});
|
|
16741
16513
|
/**
|
|
16742
16514
|
* Get Polygon Chain configuration by chain ID
|
|
16743
|
-
* @param chainId - Chain ID (137 for mainnet)
|
|
16515
|
+
* @param chainId - Chain ID (137 for mainnet, 80002 for Amoy testnet)
|
|
16744
16516
|
* @returns Polygon Chain configuration
|
|
16745
16517
|
* @throws Error if chain ID is not supported
|
|
16746
16518
|
*/
|
|
@@ -16748,13 +16520,15 @@ const getPolygonByChainId = (chainId) => {
|
|
|
16748
16520
|
switch (chainId) {
|
|
16749
16521
|
case 137:
|
|
16750
16522
|
return POLYGON_MAINNET;
|
|
16523
|
+
case 80002:
|
|
16524
|
+
return POLYGON_AMOY;
|
|
16751
16525
|
default:
|
|
16752
|
-
throw new Error(`Unsupported Polygon Chain ID: ${chainId}. Supported chains: 137 (mainnet)`);
|
|
16526
|
+
throw new Error(`Unsupported Polygon Chain ID: ${chainId}. Supported chains: 137 (mainnet), 80002 (Amoy testnet)`);
|
|
16753
16527
|
}
|
|
16754
16528
|
};
|
|
16755
16529
|
/**
|
|
16756
16530
|
* Get USDC contract address for Polygon by chain ID
|
|
16757
|
-
* @param chainId - Chain ID (137 for mainnet)
|
|
16531
|
+
* @param chainId - Chain ID (137 for mainnet, 80002 for Amoy testnet)
|
|
16758
16532
|
* @returns USDC contract address
|
|
16759
16533
|
* @throws Error if chain ID is not supported
|
|
16760
16534
|
*/
|
|
@@ -16762,8 +16536,10 @@ const getPolygonUSDCAddress = (chainId) => {
|
|
|
16762
16536
|
switch (chainId) {
|
|
16763
16537
|
case 137:
|
|
16764
16538
|
return USDC_CONTRACT_ADDRESS_POLYGON_MAINNET;
|
|
16539
|
+
case 80002:
|
|
16540
|
+
return USDC_CONTRACT_ADDRESS_POLYGON_AMOY;
|
|
16765
16541
|
default:
|
|
16766
|
-
throw new Error(`Unsupported Polygon Chain ID: ${chainId}. Supported chains: 137 (mainnet)`);
|
|
16542
|
+
throw new Error(`Unsupported Polygon Chain ID: ${chainId}. Supported chains: 137 (mainnet), 80002 (Amoy testnet)`);
|
|
16767
16543
|
}
|
|
16768
16544
|
};
|
|
16769
16545
|
|
|
@@ -16788,11 +16564,10 @@ class BaseAccount {
|
|
|
16788
16564
|
];
|
|
16789
16565
|
}
|
|
16790
16566
|
/**
|
|
16791
|
-
* Get
|
|
16792
|
-
* This
|
|
16567
|
+
* Get the LocalAccount (signer) for this account.
|
|
16568
|
+
* This can be used with the x402 library or other signing operations.
|
|
16793
16569
|
*/
|
|
16794
|
-
|
|
16795
|
-
// Return the viem account directly - it implements LocalAccount interface
|
|
16570
|
+
getLocalAccount() {
|
|
16796
16571
|
return this.account;
|
|
16797
16572
|
}
|
|
16798
16573
|
/**
|
|
@@ -16807,7 +16582,110 @@ class BaseAccount {
|
|
|
16807
16582
|
}
|
|
16808
16583
|
}
|
|
16809
16584
|
|
|
16810
|
-
|
|
16585
|
+
function toBasicAuth(token) {
|
|
16586
|
+
// Basic auth is base64("username:password"), password is blank
|
|
16587
|
+
const b64 = Buffer.from(`${token}:`).toString('base64');
|
|
16588
|
+
return `Basic ${b64}`;
|
|
16589
|
+
}
|
|
16590
|
+
/**
|
|
16591
|
+
* ATXP implementation of viem's LocalAccount interface.
|
|
16592
|
+
* Delegates signing operations to the accounts-x402 API.
|
|
16593
|
+
* Includes properties needed by x402 library for wallet client compatibility.
|
|
16594
|
+
*/
|
|
16595
|
+
class ATXPLocalAccount {
|
|
16596
|
+
constructor(address, origin, token, fetchFn = fetch) {
|
|
16597
|
+
this.address = address;
|
|
16598
|
+
this.origin = origin;
|
|
16599
|
+
this.token = token;
|
|
16600
|
+
this.fetchFn = fetchFn;
|
|
16601
|
+
this.type = 'local';
|
|
16602
|
+
/**
|
|
16603
|
+
* Get public key - required by LocalAccount interface
|
|
16604
|
+
*/
|
|
16605
|
+
this.publicKey = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
16606
|
+
/**
|
|
16607
|
+
* Source - required by LocalAccount interface (set to 'custom')
|
|
16608
|
+
*/
|
|
16609
|
+
this.source = 'custom';
|
|
16610
|
+
// x402 library expects these properties for wallet client compatibility
|
|
16611
|
+
this.account = this; // Self-reference for x402's isSignerWallet check
|
|
16612
|
+
this.chain = { id: 8453 }; // Base mainnet - could make this configurable
|
|
16613
|
+
this.transport = {}; // Empty transport object for x402 compatibility
|
|
16614
|
+
}
|
|
16615
|
+
/**
|
|
16616
|
+
* Fetch the wallet address from the /address endpoint
|
|
16617
|
+
*/
|
|
16618
|
+
static async create(origin, token, fetchFn = fetch) {
|
|
16619
|
+
// The /address endpoint uses Basic auth like other authenticated endpoints
|
|
16620
|
+
// For X402, we need the Ethereum/Base address with USDC currency
|
|
16621
|
+
const url = new URL(`${origin}/address`);
|
|
16622
|
+
url.searchParams.set('network', 'base'); // X402 operates on Base
|
|
16623
|
+
url.searchParams.set('currency', 'USDC'); // Always USDC for X402
|
|
16624
|
+
const response = await fetchFn(url.toString(), {
|
|
16625
|
+
method: 'GET',
|
|
16626
|
+
headers: {
|
|
16627
|
+
'Authorization': toBasicAuth(token)
|
|
16628
|
+
}
|
|
16629
|
+
});
|
|
16630
|
+
if (!response.ok) {
|
|
16631
|
+
const errorText = await response.text();
|
|
16632
|
+
throw new Error(`Failed to fetch destination address: ${response.status} ${response.statusText} ${errorText}`);
|
|
16633
|
+
}
|
|
16634
|
+
const data = await response.json();
|
|
16635
|
+
const address = data.address;
|
|
16636
|
+
if (!address) {
|
|
16637
|
+
throw new Error('Address endpoint did not return an address');
|
|
16638
|
+
}
|
|
16639
|
+
// Check that the account is an Ethereum/Base account (required for X402/EVM operations)
|
|
16640
|
+
const network = data.network;
|
|
16641
|
+
if (!network) {
|
|
16642
|
+
throw new Error('Address endpoint did not return a network');
|
|
16643
|
+
}
|
|
16644
|
+
if (network !== 'ethereum' && network !== 'base') {
|
|
16645
|
+
throw new Error(`ATXPLocalAccount requires an Ethereum/Base account, but got ${network} account`);
|
|
16646
|
+
}
|
|
16647
|
+
return new ATXPLocalAccount(address, origin, token, fetchFn);
|
|
16648
|
+
}
|
|
16649
|
+
/**
|
|
16650
|
+
* Sign a typed data structure using EIP-712
|
|
16651
|
+
* This is what x402 library will call for EIP-3009 authorization
|
|
16652
|
+
*/
|
|
16653
|
+
async signTypedData(typedData) {
|
|
16654
|
+
const response = await this.fetchFn(`${this.origin}/sign-typed-data`, {
|
|
16655
|
+
method: 'POST',
|
|
16656
|
+
headers: {
|
|
16657
|
+
'Authorization': toBasicAuth(this.token),
|
|
16658
|
+
'Content-Type': 'application/json',
|
|
16659
|
+
},
|
|
16660
|
+
body: JSON.stringify({
|
|
16661
|
+
typedData
|
|
16662
|
+
})
|
|
16663
|
+
});
|
|
16664
|
+
if (!response.ok) {
|
|
16665
|
+
const errorText = await response.text();
|
|
16666
|
+
throw new Error(`Failed to sign typed data: ${response.status} ${response.statusText} ${errorText}`);
|
|
16667
|
+
}
|
|
16668
|
+
const result = await response.json();
|
|
16669
|
+
return result.signature;
|
|
16670
|
+
}
|
|
16671
|
+
/**
|
|
16672
|
+
* Sign a message - required by LocalAccount interface but not used for X402
|
|
16673
|
+
*/
|
|
16674
|
+
async signMessage(_) {
|
|
16675
|
+
throw new Error('Message signing not implemented for ATXP local account');
|
|
16676
|
+
}
|
|
16677
|
+
/**
|
|
16678
|
+
* Sign a transaction - required by LocalAccount interface but not used for X402
|
|
16679
|
+
*/
|
|
16680
|
+
async signTransaction(_transaction, _args) {
|
|
16681
|
+
throw new Error('Transaction signing not implemented for ATXP local account');
|
|
16682
|
+
}
|
|
16683
|
+
}
|
|
16684
|
+
|
|
16685
|
+
Object.defineProperty(exports, "ATXPAccount", {
|
|
16686
|
+
enumerable: true,
|
|
16687
|
+
get: function () { return common.ATXPAccount; }
|
|
16688
|
+
});
|
|
16811
16689
|
exports.ATXPDestinationMaker = ATXPDestinationMaker;
|
|
16812
16690
|
exports.ATXPLocalAccount = ATXPLocalAccount;
|
|
16813
16691
|
exports.BaseAccount = BaseAccount;
|
|
@@ -16816,6 +16694,7 @@ exports.DEFAULT_CLIENT_CONFIG = DEFAULT_CLIENT_CONFIG;
|
|
|
16816
16694
|
exports.InsufficientFundsError = InsufficientFundsError;
|
|
16817
16695
|
exports.OAuthAuthenticationRequiredError = OAuthAuthenticationRequiredError;
|
|
16818
16696
|
exports.OAuthClient = OAuthClient;
|
|
16697
|
+
exports.POLYGON_AMOY = POLYGON_AMOY;
|
|
16819
16698
|
exports.POLYGON_MAINNET = POLYGON_MAINNET;
|
|
16820
16699
|
exports.PassthroughDestinationMaker = PassthroughDestinationMaker;
|
|
16821
16700
|
exports.PaymentNetworkError = PaymentNetworkError;
|
|
@@ -16823,6 +16702,7 @@ exports.SolanaAccount = SolanaAccount;
|
|
|
16823
16702
|
exports.SolanaPaymentMaker = SolanaPaymentMaker;
|
|
16824
16703
|
exports.USDC_CONTRACT_ADDRESS_BASE = USDC_CONTRACT_ADDRESS_BASE;
|
|
16825
16704
|
exports.USDC_CONTRACT_ADDRESS_BASE_SEPOLIA = USDC_CONTRACT_ADDRESS_BASE_SEPOLIA;
|
|
16705
|
+
exports.USDC_CONTRACT_ADDRESS_POLYGON_AMOY = USDC_CONTRACT_ADDRESS_POLYGON_AMOY;
|
|
16826
16706
|
exports.USDC_CONTRACT_ADDRESS_POLYGON_MAINNET = USDC_CONTRACT_ADDRESS_POLYGON_MAINNET;
|
|
16827
16707
|
exports.USDC_CONTRACT_ADDRESS_WORLD_MAINNET = USDC_CONTRACT_ADDRESS_WORLD_MAINNET;
|
|
16828
16708
|
exports.USDC_CONTRACT_ADDRESS_WORLD_SEPOLIA = USDC_CONTRACT_ADDRESS_WORLD_SEPOLIA;
|
|
@@ -16834,6 +16714,7 @@ exports.atxpFetch = atxpFetch;
|
|
|
16834
16714
|
exports.buildClientConfig = buildClientConfig;
|
|
16835
16715
|
exports.buildStreamableTransport = buildStreamableTransport;
|
|
16836
16716
|
exports.getBaseUSDCAddress = getBaseUSDCAddress;
|
|
16717
|
+
exports.getPolygonAmoyWithRPC = getPolygonAmoyWithRPC;
|
|
16837
16718
|
exports.getPolygonByChainId = getPolygonByChainId;
|
|
16838
16719
|
exports.getPolygonMainnetWithRPC = getPolygonMainnetWithRPC;
|
|
16839
16720
|
exports.getPolygonUSDCAddress = getPolygonUSDCAddress;
|