@ampersend_ai/ampersend-sdk 0.0.19 → 0.0.21
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/ampersend/client.d.ts +4 -9
- package/dist/ampersend/client.d.ts.map +1 -1
- package/dist/ampersend/client.js +25 -21
- package/dist/ampersend/client.js.map +1 -1
- package/dist/ampersend/treasurer.d.ts +14 -79
- package/dist/ampersend/treasurer.d.ts.map +1 -1
- package/dist/ampersend/treasurer.js +34 -102
- package/dist/ampersend/treasurer.js.map +1 -1
- package/dist/ampersend/types.d.ts +342 -336
- package/dist/ampersend/types.d.ts.map +1 -1
- package/dist/ampersend/types.js +110 -149
- package/dist/ampersend/types.js.map +1 -1
- package/dist/ampersend/zod-bridge.d.ts +15 -0
- package/dist/ampersend/zod-bridge.d.ts.map +1 -0
- package/dist/ampersend/zod-bridge.js +29 -0
- package/dist/ampersend/zod-bridge.js.map +1 -0
- package/dist/cli/commands/fetch.d.ts.map +1 -1
- package/dist/cli/commands/fetch.js.map +1 -1
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +6 -1
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/client/client.d.ts +0 -3
- package/dist/mcp/client/client.d.ts.map +1 -1
- package/dist/mcp/client/client.js +10 -14
- package/dist/mcp/client/client.js.map +1 -1
- package/dist/mcp/client/factory.d.ts +0 -2
- package/dist/mcp/client/factory.d.ts.map +1 -1
- package/dist/mcp/client/factory.js +0 -3
- package/dist/mcp/client/factory.js.map +1 -1
- package/dist/mcp/client/middleware.d.ts +0 -3
- package/dist/mcp/client/middleware.d.ts.map +1 -1
- package/dist/mcp/client/middleware.js +9 -12
- package/dist/mcp/client/middleware.js.map +1 -1
- package/dist/mcp/client/protocol.d.ts +81 -85
- package/dist/mcp/client/protocol.d.ts.map +1 -1
- package/dist/mcp/client/protocol.js +17 -15
- package/dist/mcp/client/protocol.js.map +1 -1
- package/dist/mcp/client/types.d.ts +6 -19
- package/dist/mcp/client/types.d.ts.map +1 -1
- package/dist/mcp/proxy/cli.d.ts.map +1 -1
- package/dist/mcp/proxy/cli.js +0 -1
- package/dist/mcp/proxy/cli.js.map +1 -1
- package/dist/mcp/proxy/env.d.ts +0 -9
- package/dist/mcp/proxy/env.d.ts.map +1 -1
- package/dist/mcp/proxy/env.js +0 -2
- package/dist/mcp/proxy/env.js.map +1 -1
- package/dist/mcp/proxy/factory.d.ts +0 -2
- package/dist/mcp/proxy/factory.d.ts.map +1 -1
- package/dist/mcp/proxy/factory.js +0 -3
- package/dist/mcp/proxy/factory.js.map +1 -1
- package/dist/mcp/server/fastmcp/middleware.d.ts +9 -29
- package/dist/mcp/server/fastmcp/middleware.d.ts.map +1 -1
- package/dist/mcp/server/fastmcp/middleware.js +10 -42
- package/dist/mcp/server/fastmcp/middleware.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/x402/envelopes.d.ts +62 -0
- package/dist/x402/envelopes.d.ts.map +1 -0
- package/dist/x402/envelopes.js +73 -0
- package/dist/x402/envelopes.js.map +1 -0
- package/dist/x402/http/client.d.ts +37 -0
- package/dist/x402/http/client.d.ts.map +1 -0
- package/dist/x402/http/client.js +159 -0
- package/dist/x402/http/client.js.map +1 -0
- package/dist/x402/http/factory.d.ts +11 -25
- package/dist/x402/http/factory.d.ts.map +1 -1
- package/dist/x402/http/factory.js +11 -22
- package/dist/x402/http/factory.js.map +1 -1
- package/dist/x402/http/index.d.ts +4 -1
- package/dist/x402/http/index.d.ts.map +1 -1
- package/dist/x402/http/index.js +2 -1
- package/dist/x402/http/index.js.map +1 -1
- package/dist/x402/index.d.ts +4 -1
- package/dist/x402/index.d.ts.map +1 -1
- package/dist/x402/index.js +3 -2
- package/dist/x402/index.js.map +1 -1
- package/dist/x402/treasurer.d.ts +22 -47
- package/dist/x402/treasurer.d.ts.map +1 -1
- package/dist/x402/treasurers/naive.d.ts +4 -40
- package/dist/x402/treasurers/naive.d.ts.map +1 -1
- package/dist/x402/treasurers/naive.js +7 -44
- package/dist/x402/treasurers/naive.js.map +1 -1
- package/dist/x402/wallet.d.ts +7 -32
- package/dist/x402/wallet.d.ts.map +1 -1
- package/dist/x402/wallet.js +0 -3
- package/dist/x402/wallet.js.map +1 -1
- package/dist/x402/wallets/account/wallet.d.ts +9 -30
- package/dist/x402/wallets/account/wallet.d.ts.map +1 -1
- package/dist/x402/wallets/account/wallet.js +30 -37
- package/dist/x402/wallets/account/wallet.js.map +1 -1
- package/dist/x402/wallets/index.d.ts +0 -1
- package/dist/x402/wallets/index.d.ts.map +1 -1
- package/dist/x402/wallets/index.js +0 -1
- package/dist/x402/wallets/index.js.map +1 -1
- package/dist/x402/wallets/smart-account/chain.d.ts +4 -0
- package/dist/x402/wallets/smart-account/chain.d.ts.map +1 -0
- package/dist/x402/wallets/smart-account/chain.js +12 -0
- package/dist/x402/wallets/smart-account/chain.js.map +1 -0
- package/dist/x402/wallets/smart-account/cosigned.d.ts +7 -33
- package/dist/x402/wallets/smart-account/cosigned.d.ts.map +1 -1
- package/dist/x402/wallets/smart-account/cosigned.js +28 -51
- package/dist/x402/wallets/smart-account/cosigned.js.map +1 -1
- package/dist/x402/wallets/smart-account/exact.d.ts +6 -20
- package/dist/x402/wallets/smart-account/exact.d.ts.map +1 -1
- package/dist/x402/wallets/smart-account/exact.js +33 -43
- package/dist/x402/wallets/smart-account/exact.js.map +1 -1
- package/dist/x402/wallets/smart-account/wallet.d.ts +6 -39
- package/dist/x402/wallets/smart-account/wallet.d.ts.map +1 -1
- package/dist/x402/wallets/smart-account/wallet.js +9 -36
- package/dist/x402/wallets/smart-account/wallet.js.map +1 -1
- package/package.json +4 -4
- package/dist/x402/http/adapter.d.ts +0 -38
- package/dist/x402/http/adapter.d.ts.map +0 -1
- package/dist/x402/http/adapter.js +0 -193
- package/dist/x402/http/adapter.js.map +0 -1
- package/dist/x402/http/v2-adapter.d.ts +0 -56
- package/dist/x402/http/v2-adapter.d.ts.map +0 -1
- package/dist/x402/http/v2-adapter.js +0 -94
- package/dist/x402/http/v2-adapter.js.map +0 -1
package/dist/x402/wallet.d.ts
CHANGED
|
@@ -1,43 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PaymentAuthorization, PaymentInstruction } from "./envelopes.ts";
|
|
2
2
|
import type { ServerAuthorizationData } from "./types.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Error thrown when wallet cannot create a payment
|
|
5
|
-
*/
|
|
6
3
|
export declare class WalletError extends Error {
|
|
7
4
|
cause?: Error | undefined;
|
|
8
5
|
constructor(message: string, cause?: Error | undefined);
|
|
9
6
|
}
|
|
10
7
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* An X402Wallet is responsible for creating cryptographically signed payment payloads
|
|
14
|
-
* that can be submitted to sellers. Different wallet implementations support
|
|
15
|
-
* different account types (EOA, smart accounts, etc.).
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* class AccountWallet implements X402Wallet {
|
|
20
|
-
* constructor(private account: Account) {}
|
|
8
|
+
* Signs a {@link PaymentInstruction} into a {@link PaymentAuthorization}.
|
|
21
9
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* }
|
|
26
|
-
* // Create and sign payment
|
|
27
|
-
* return signedPayment
|
|
28
|
-
* }
|
|
29
|
-
* }
|
|
30
|
-
* ```
|
|
10
|
+
* Implementations read fields via {@link acceptedOf} / {@link amountOf} and
|
|
11
|
+
* return via {@link buildAuthorization}, which handles the v1/v2 envelope
|
|
12
|
+
* packaging (including v2's `resource`/`accepted`/`extensions` echo).
|
|
31
13
|
*/
|
|
32
14
|
export interface X402Wallet {
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
* @param requirements - Payment requirements from seller
|
|
37
|
-
* @param serverAuthorization - Optional server co-signature data (for co-signed smart account keys)
|
|
38
|
-
* @returns Signed payment payload ready for submission
|
|
39
|
-
* @throws {WalletError} If unable to create payment (unsupported scheme, insufficient funds, etc.)
|
|
40
|
-
*/
|
|
41
|
-
createPayment(requirements: PaymentRequirements, serverAuthorization?: ServerAuthorizationData): Promise<PaymentPayload>;
|
|
15
|
+
/** @throws {WalletError} for unsupported schemes, insufficient funds, etc. */
|
|
16
|
+
createPayment(instruction: PaymentInstruction, serverAuthorization?: ServerAuthorizationData): Promise<PaymentAuthorization>;
|
|
42
17
|
}
|
|
43
18
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/x402/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/x402/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAEzD,qBAAa,WAAY,SAAQ,KAAK;IAG3B,KAAK,CAAC,EAAE,KAAK;gBADpB,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,KAAK,YAAA;CAKvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,8EAA8E;IAC9E,aAAa,CACX,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,CAAC,EAAE,uBAAuB,GAC5C,OAAO,CAAC,oBAAoB,CAAC,CAAA;CACjC"}
|
package/dist/x402/wallet.js
CHANGED
package/dist/x402/wallet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/x402/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/x402/wallet.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAG3B;IAFT,YACE,OAAe,EACR,KAAa;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAA;QAFP,UAAK,GAAL,KAAK,CAAQ;QAGpB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;IAC3B,CAAC;CACF"}
|
|
@@ -1,41 +1,20 @@
|
|
|
1
1
|
import type { Hex, LocalAccount } from "viem";
|
|
2
|
-
import type
|
|
3
|
-
import type { ServerAuthorizationData } from "
|
|
2
|
+
import { type PaymentAuthorization, type PaymentInstruction } from "../../envelopes.ts";
|
|
3
|
+
import type { ServerAuthorizationData } from "../../types.ts";
|
|
4
4
|
import { type X402Wallet } from "../../wallet.ts";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Supports the "exact" payment scheme.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { privateKeyToAccount } from "viem/accounts"
|
|
14
|
-
*
|
|
15
|
-
* // From viem Account
|
|
16
|
-
* const account = privateKeyToAccount("0x...")
|
|
17
|
-
* const wallet = new AccountWallet(account)
|
|
18
|
-
*
|
|
19
|
-
* // From private key directly
|
|
20
|
-
* const wallet = AccountWallet.fromPrivateKey("0x...")
|
|
21
|
-
* ```
|
|
6
|
+
* EOA wallet for x402 `exact` on EVM. A `LocalAccount` is sufficient for
|
|
7
|
+
* EIP-3009 and base Permit2; EIP-2612 permit enrichment is skipped because it
|
|
8
|
+
* needs `readContract`, which `LocalAccount` lacks.
|
|
22
9
|
*/
|
|
23
10
|
export declare class AccountWallet implements X402Wallet {
|
|
24
11
|
private account;
|
|
12
|
+
private signer;
|
|
13
|
+
private schemeV1;
|
|
14
|
+
private schemeV2;
|
|
25
15
|
constructor(account: LocalAccount);
|
|
26
|
-
/**
|
|
27
|
-
* Creates an AccountWallet from a private key
|
|
28
|
-
*/
|
|
29
16
|
static fromPrivateKey(privateKey: Hex): AccountWallet;
|
|
30
|
-
|
|
31
|
-
* Creates a payment payload from requirements.
|
|
32
|
-
* Only supports "exact" payment scheme.
|
|
33
|
-
* Note: serverAuthorization parameter is ignored for EOA wallets (only used by SmartAccountWallet)
|
|
34
|
-
*/
|
|
35
|
-
createPayment(requirements: PaymentRequirements, _serverAuthorization?: ServerAuthorizationData): Promise<PaymentPayload>;
|
|
36
|
-
/**
|
|
37
|
-
* Returns the account address
|
|
38
|
-
*/
|
|
17
|
+
createPayment(instruction: PaymentInstruction, serverAuthorization?: ServerAuthorizationData): Promise<PaymentAuthorization>;
|
|
39
18
|
get address(): Hex;
|
|
40
19
|
}
|
|
41
20
|
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../../src/x402/wallets/account/wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../../src/x402/wallets/account/wallet.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAG7C,OAAO,EAAkC,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE9D;;;;GAIG;AACH,qBAAa,aAAc,YAAW,UAAU;IAC9C,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,OAAO,EAAE,YAAY;IAUjC,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,GAAG,GAAG,aAAa;IAI/C,aAAa,CACjB,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,CAAC,EAAE,uBAAuB,GAC5C,OAAO,CAAC,oBAAoB,CAAC;IAiChC,IAAI,OAAO,IAAI,GAAG,CAEjB;CACF"}
|
|
@@ -1,59 +1,52 @@
|
|
|
1
|
+
import { ExactEvmScheme, toClientEvmSigner } from "@x402/evm";
|
|
2
|
+
import { ExactEvmSchemeV1 } from "@x402/evm/v1";
|
|
1
3
|
import { privateKeyToAccount } from "viem/accounts";
|
|
2
|
-
import {
|
|
4
|
+
import { acceptedOf, buildAuthorization } from "../../envelopes.js";
|
|
3
5
|
import { WalletError } from "../../wallet.js";
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Supports the "exact" payment scheme.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import { privateKeyToAccount } from "viem/accounts"
|
|
13
|
-
*
|
|
14
|
-
* // From viem Account
|
|
15
|
-
* const account = privateKeyToAccount("0x...")
|
|
16
|
-
* const wallet = new AccountWallet(account)
|
|
17
|
-
*
|
|
18
|
-
* // From private key directly
|
|
19
|
-
* const wallet = AccountWallet.fromPrivateKey("0x...")
|
|
20
|
-
* ```
|
|
7
|
+
* EOA wallet for x402 `exact` on EVM. A `LocalAccount` is sufficient for
|
|
8
|
+
* EIP-3009 and base Permit2; EIP-2612 permit enrichment is skipped because it
|
|
9
|
+
* needs `readContract`, which `LocalAccount` lacks.
|
|
21
10
|
*/
|
|
22
11
|
export class AccountWallet {
|
|
23
12
|
account;
|
|
13
|
+
signer;
|
|
14
|
+
schemeV1;
|
|
15
|
+
schemeV2;
|
|
24
16
|
constructor(account) {
|
|
25
17
|
this.account = account;
|
|
18
|
+
this.signer = toClientEvmSigner({
|
|
19
|
+
address: account.address,
|
|
20
|
+
signTypedData: (msg) => account.signTypedData(msg),
|
|
21
|
+
});
|
|
22
|
+
this.schemeV1 = new ExactEvmSchemeV1(this.signer);
|
|
23
|
+
this.schemeV2 = new ExactEvmScheme(this.signer);
|
|
26
24
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Creates an AccountWallet from a private key
|
|
29
|
-
*/
|
|
30
25
|
static fromPrivateKey(privateKey) {
|
|
31
26
|
return new AccountWallet(privateKeyToAccount(privateKey));
|
|
32
27
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
async createPayment(requirements, _serverAuthorization) {
|
|
39
|
-
if (requirements.scheme !== "exact") {
|
|
40
|
-
throw new WalletError(`Unsupported payment scheme: ${requirements.scheme}. AccountWallet only supports "exact".`);
|
|
28
|
+
async createPayment(instruction, serverAuthorization) {
|
|
29
|
+
if (serverAuthorization) {
|
|
30
|
+
throw new WalletError("AccountWallet received a co-signed authorization from the server, but EOA accounts " +
|
|
31
|
+
"cannot produce ERC-1271 co-signed payments. Use SmartAccountWallet for co-signed agent keys.");
|
|
41
32
|
}
|
|
33
|
+
const accepted = acceptedOf(instruction);
|
|
34
|
+
if (accepted.scheme !== "exact") {
|
|
35
|
+
throw new WalletError(`Unsupported payment scheme: ${accepted.scheme}. AccountWallet only supports "exact".`);
|
|
36
|
+
}
|
|
37
|
+
// Zod-inferred shape → upstream v2-surface shape. Nominal mismatch only;
|
|
38
|
+
// each scheme re-narrows to the version it needs at runtime.
|
|
39
|
+
const requirements = accepted;
|
|
42
40
|
try {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const payment = JSON.parse(decoded);
|
|
48
|
-
return payment;
|
|
41
|
+
const result = instruction.protocol === "x402-v1"
|
|
42
|
+
? await this.schemeV1.createPaymentPayload(1, requirements)
|
|
43
|
+
: await this.schemeV2.createPaymentPayload(2, requirements, instruction.request.extensions ? { extensions: instruction.request.extensions } : undefined);
|
|
44
|
+
return buildAuthorization(instruction, result.payload);
|
|
49
45
|
}
|
|
50
46
|
catch (error) {
|
|
51
47
|
throw new WalletError(`Failed to create payment: ${error instanceof Error ? error.message : String(error)}`, error instanceof Error ? error : undefined);
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Returns the account address
|
|
56
|
-
*/
|
|
57
50
|
get address() {
|
|
58
51
|
return this.account.address;
|
|
59
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../../src/x402/wallets/account/wallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../../../src/x402/wallets/account/wallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAwB,MAAM,WAAW,CAAA;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAsD,MAAM,oBAAoB,CAAA;AAEvH,OAAO,EAAE,WAAW,EAAmB,MAAM,iBAAiB,CAAA;AAE9D;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAChB,OAAO,CAAc;IACrB,MAAM,CAAiB;IACvB,QAAQ,CAAkB;IAC1B,QAAQ,CAAgB;IAEhC,YAAY,OAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC;YAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC;SACnD,CAAC,CAAA;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC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CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EACrF,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAC3C,CAAA;QACH,CAAC;IACH,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA;IAC7B,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/x402/wallets/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAI9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAEvF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,CAAA;IACX,UAAU,EAAE,GAAG,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,eAAe,CAAA;IACrB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,oBAAoB,EAAE,GAAG,CAAA;IACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/x402/wallets/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAI9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAEvF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,KAAK,CAAA;IACX,UAAU,EAAE,GAAG,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,eAAe,CAAA;IACrB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,oBAAoB,EAAE,GAAG,CAAA;IACzB,gBAAgB,EAAE,OAAO,CAAA;IACzB,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,wBAAwB,CAAA;AAErE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAWvE"}
|
|
@@ -16,7 +16,6 @@ export function createWalletFromConfig(config) {
|
|
|
16
16
|
return new SmartAccountWallet({
|
|
17
17
|
smartAccountAddress: config.smartAccountAddress,
|
|
18
18
|
sessionKeyPrivateKey: config.sessionKeyPrivateKey,
|
|
19
|
-
chainId: config.chainId,
|
|
20
19
|
validatorAddress: config.validatorAddress,
|
|
21
20
|
...(config.coSignerValidatorAddress != null && { coSignerValidatorAddress: config.coSignerValidatorAddress }),
|
|
22
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/x402/wallets/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAA2B,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/x402/wallets/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAA2B,MAAM,2BAA2B,CAAA;AA0BvF;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAoB;IACzD,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,OAAO,IAAI,kBAAkB,CAAC;QAC5B,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;QACjD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,GAAG,CAAC,MAAM,CAAC,wBAAwB,IAAI,IAAI,IAAI,EAAE,wBAAwB,EAAE,MAAM,CAAC,wBAAwB,EAAE,CAAC;KAC9G,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PaymentInstruction } from "../../envelopes.ts";
|
|
2
|
+
/** v1 looks up the network name; v2 parses `eip155:N`. Returns `null` for unsupported networks. */
|
|
3
|
+
export declare function chainIdOf(instruction: PaymentInstruction): number | null;
|
|
4
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../../src/x402/wallets/smart-account/chain.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAExE,mGAAmG;AACnG,wBAAgB,SAAS,CAAC,WAAW,EAAE,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAOxE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EVM_NETWORK_CHAIN_ID_MAP } from "@x402/evm/v1";
|
|
2
|
+
import { acceptedOf } from "../../envelopes.js";
|
|
3
|
+
/** v1 looks up the network name; v2 parses `eip155:N`. Returns `null` for unsupported networks. */
|
|
4
|
+
export function chainIdOf(instruction) {
|
|
5
|
+
const network = acceptedOf(instruction).network;
|
|
6
|
+
if (instruction.protocol === "x402-v1") {
|
|
7
|
+
return EVM_NETWORK_CHAIN_ID_MAP[network] ?? null;
|
|
8
|
+
}
|
|
9
|
+
const match = /^eip155:(\d+)$/.exec(network);
|
|
10
|
+
return match ? Number(match[1]) : null;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=chain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../../src/x402/wallets/smart-account/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAEvD,OAAO,EAAE,UAAU,EAA2B,MAAM,oBAAoB,CAAA;AAExE,mGAAmG;AACnG,MAAM,UAAU,SAAS,CAAC,WAA+B;IACvD,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO,CAAA;IAC/C,IAAI,WAAW,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACvC,OAAQ,wBAA6D,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;IACxF,CAAC;IACD,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC5C,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACxC,CAAC"}
|
|
@@ -1,46 +1,20 @@
|
|
|
1
1
|
import { type Address, type Hex, type TypedDataDefinition } from "viem";
|
|
2
|
-
import type
|
|
2
|
+
import { type PaymentAuthorization, type PaymentInstruction } from "../../envelopes.ts";
|
|
3
3
|
import type { ServerAuthorizationData } from "../../types.ts";
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for creating a co-signed payment
|
|
6
|
-
*/
|
|
7
4
|
export interface CoSignedPaymentConfig {
|
|
8
|
-
/** Smart account address (payment sender) */
|
|
9
5
|
smartAccountAddress: Address;
|
|
10
|
-
/** Session key private key for signing */
|
|
11
6
|
sessionKeyPrivateKey: Hex;
|
|
12
|
-
/** Chain ID for the blockchain network */
|
|
13
|
-
chainId: number;
|
|
14
|
-
/** CoSignerValidator address */
|
|
15
7
|
coSignerValidatorAddress: Address;
|
|
16
8
|
}
|
|
17
9
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* Combines agent signature + server signature according to CoSignerValidator format:
|
|
21
|
-
* 1. Sign typed data with agent key (raw ECDSA)
|
|
22
|
-
* 2. Combine: abi.encode(agentSig, serverSig)
|
|
23
|
-
* 3. Wrap for ERC-1271: encodePacked(validatorAddress, combined)
|
|
24
|
-
*
|
|
25
|
-
* @param agentPrivateKey - Agent's session key private key
|
|
26
|
-
* @param typedDataParams - EIP-712 typed data to sign
|
|
27
|
-
* @param serverSignature - Server's ECDSA signature (65 bytes as hex)
|
|
28
|
-
* @param coSignerValidatorAddress - CoSignerValidator contract address
|
|
29
|
-
* @returns ERC-1271 formatted signature
|
|
10
|
+
* CoSignerValidator ERC-1271 signature: agent signs → `abi.encode(agentSig, serverSig)`
|
|
11
|
+
* → `encodePacked(validator, combined)`.
|
|
30
12
|
*/
|
|
31
13
|
export declare function encodeCoSignedERC1271Signature(agentPrivateKey: Hex, typedDataParams: TypedDataDefinition, serverSignature: Hex, coSignerValidatorAddress: Address): Promise<Hex>;
|
|
32
14
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* authorization data and co-signature. The agent key adds its signature and
|
|
37
|
-
* combines them for ERC-1271 validation via CoSignerValidator.
|
|
38
|
-
*
|
|
39
|
-
* @param requirements - Payment requirements from the x402 server
|
|
40
|
-
* @param config - Configuration for the smart account wallet
|
|
41
|
-
* @param serverAuthorization - Server-provided authorization data and co-signature
|
|
42
|
-
* @returns Payment payload ready to send to x402 server
|
|
43
|
-
* @throws Error if requirements are invalid or signing fails
|
|
15
|
+
* Sign a co-signed `exact` instruction. Server supplies ERC-3009
|
|
16
|
+
* authorization data + its signature; agent adds its own and the pair is
|
|
17
|
+
* validated via CoSignerValidator under ERC-1271.
|
|
44
18
|
*/
|
|
45
|
-
export declare function createCoSignedPayment(
|
|
19
|
+
export declare function createCoSignedPayment(instruction: PaymentInstruction, config: CoSignedPaymentConfig, serverAuthorization: ServerAuthorizationData): Promise<PaymentAuthorization>;
|
|
46
20
|
//# sourceMappingURL=cosigned.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosigned.d.ts","sourceRoot":"","sources":["../../../../src/x402/wallets/smart-account/cosigned.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,mBAAmB,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"cosigned.d.ts","sourceRoot":"","sources":["../../../../src/x402/wallets/smart-account/cosigned.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAI1G,OAAO,EAAkC,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAG7D,MAAM,WAAW,qBAAqB;IACpC,mBAAmB,EAAE,OAAO,CAAA;IAC5B,oBAAoB,EAAE,GAAG,CAAA;IACzB,wBAAwB,EAAE,OAAO,CAAA;CAClC;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,eAAe,EAAE,GAAG,EACpB,eAAe,EAAE,mBAAmB,EACpC,eAAe,EAAE,GAAG,EACpB,wBAAwB,EAAE,OAAO,GAChC,OAAO,CAAC,GAAG,CAAC,CAUd;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,kBAAkB,EAC/B,MAAM,EAAE,qBAAqB,EAC7B,mBAAmB,EAAE,uBAAuB,GAC3C,OAAO,CAAC,oBAAoB,CAAC,CAyD/B"}
|
|
@@ -1,57 +1,41 @@
|
|
|
1
1
|
import { encodeAbiParameters, encodePacked } from "viem";
|
|
2
2
|
import { privateKeyToAccount } from "viem/accounts";
|
|
3
3
|
import { TRANSFER_WITH_AUTHORIZATION_TYPE } from "../../../smart-account/eip712-types.js";
|
|
4
|
+
import { acceptedOf, buildAuthorization } from "../../envelopes.js";
|
|
5
|
+
import { chainIdOf } from "./chain.js";
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Combines agent signature + server signature according to CoSignerValidator format:
|
|
8
|
-
* 1. Sign typed data with agent key (raw ECDSA)
|
|
9
|
-
* 2. Combine: abi.encode(agentSig, serverSig)
|
|
10
|
-
* 3. Wrap for ERC-1271: encodePacked(validatorAddress, combined)
|
|
11
|
-
*
|
|
12
|
-
* @param agentPrivateKey - Agent's session key private key
|
|
13
|
-
* @param typedDataParams - EIP-712 typed data to sign
|
|
14
|
-
* @param serverSignature - Server's ECDSA signature (65 bytes as hex)
|
|
15
|
-
* @param coSignerValidatorAddress - CoSignerValidator contract address
|
|
16
|
-
* @returns ERC-1271 formatted signature
|
|
7
|
+
* CoSignerValidator ERC-1271 signature: agent signs → `abi.encode(agentSig, serverSig)`
|
|
8
|
+
* → `encodePacked(validator, combined)`.
|
|
17
9
|
*/
|
|
18
10
|
export async function encodeCoSignedERC1271Signature(agentPrivateKey, typedDataParams, serverSignature, coSignerValidatorAddress) {
|
|
19
|
-
// 1. Sign with agent key
|
|
20
11
|
const agentAccount = privateKeyToAccount(agentPrivateKey);
|
|
21
12
|
const agentSignature = await agentAccount.signTypedData(typedDataParams);
|
|
22
|
-
// 2. Combine signatures: abi.encode(bytes agentSig, bytes serverSig)
|
|
23
13
|
const combinedSignature = encodeAbiParameters([{ type: "bytes" }, { type: "bytes" }], [agentSignature, serverSignature]);
|
|
24
|
-
// 3. Encode for ERC-1271: encodePacked(address validator, bytes signature)
|
|
25
14
|
return encodePacked(["address", "bytes"], [coSignerValidatorAddress, combinedSignature]);
|
|
26
15
|
}
|
|
27
16
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* authorization data and co-signature. The agent key adds its signature and
|
|
32
|
-
* combines them for ERC-1271 validation via CoSignerValidator.
|
|
33
|
-
*
|
|
34
|
-
* @param requirements - Payment requirements from the x402 server
|
|
35
|
-
* @param config - Configuration for the smart account wallet
|
|
36
|
-
* @param serverAuthorization - Server-provided authorization data and co-signature
|
|
37
|
-
* @returns Payment payload ready to send to x402 server
|
|
38
|
-
* @throws Error if requirements are invalid or signing fails
|
|
17
|
+
* Sign a co-signed `exact` instruction. Server supplies ERC-3009
|
|
18
|
+
* authorization data + its signature; agent adds its own and the pair is
|
|
19
|
+
* validated via CoSignerValidator under ERC-1271.
|
|
39
20
|
*/
|
|
40
|
-
export async function createCoSignedPayment(
|
|
21
|
+
export async function createCoSignedPayment(instruction, config, serverAuthorization) {
|
|
41
22
|
const { authorizationData, serverSignature } = serverAuthorization;
|
|
42
|
-
|
|
43
|
-
const domainName =
|
|
44
|
-
const domainVersion =
|
|
23
|
+
const accepted = acceptedOf(instruction);
|
|
24
|
+
const domainName = accepted.extra?.name;
|
|
25
|
+
const domainVersion = accepted.extra?.version;
|
|
45
26
|
if (!domainName || !domainVersion) {
|
|
46
|
-
throw new Error("
|
|
27
|
+
throw new Error("accepted.extra must contain 'name' and 'version' for EIP-712 domain");
|
|
28
|
+
}
|
|
29
|
+
const chainId = chainIdOf(instruction);
|
|
30
|
+
if (chainId === null) {
|
|
31
|
+
throw new Error(`Unsupported network "${accepted.network}" — use a known v1 name or CAIP-2 "eip155:N".`);
|
|
47
32
|
}
|
|
48
|
-
// Construct EIP-712 typed data from server-provided authorization data
|
|
49
33
|
const typedData = {
|
|
50
34
|
domain: {
|
|
51
35
|
name: domainName,
|
|
52
36
|
version: domainVersion,
|
|
53
|
-
chainId
|
|
54
|
-
verifyingContract:
|
|
37
|
+
chainId,
|
|
38
|
+
verifyingContract: accepted.asset,
|
|
55
39
|
},
|
|
56
40
|
types: {
|
|
57
41
|
TransferWithAuthorization: TRANSFER_WITH_AUTHORIZATION_TYPE,
|
|
@@ -66,25 +50,18 @@ export async function createCoSignedPayment(requirements, config, serverAuthoriz
|
|
|
66
50
|
nonce: authorizationData.nonce,
|
|
67
51
|
},
|
|
68
52
|
};
|
|
69
|
-
// Encode co-signed signature
|
|
70
53
|
const signature = await encodeCoSignedERC1271Signature(config.sessionKeyPrivateKey, typedData, serverSignature, config.coSignerValidatorAddress);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
to: authorizationData.to,
|
|
81
|
-
value: authorizationData.value,
|
|
82
|
-
validAfter: authorizationData.validAfter,
|
|
83
|
-
validBefore: authorizationData.validBefore,
|
|
84
|
-
nonce: authorizationData.nonce,
|
|
85
|
-
},
|
|
54
|
+
const signedPayload = {
|
|
55
|
+
signature: signature,
|
|
56
|
+
authorization: {
|
|
57
|
+
from: authorizationData.from,
|
|
58
|
+
to: authorizationData.to,
|
|
59
|
+
value: authorizationData.value,
|
|
60
|
+
validAfter: authorizationData.validAfter,
|
|
61
|
+
validBefore: authorizationData.validBefore,
|
|
62
|
+
nonce: authorizationData.nonce,
|
|
86
63
|
},
|
|
87
64
|
};
|
|
88
|
-
return
|
|
65
|
+
return buildAuthorization(instruction, signedPayload);
|
|
89
66
|
}
|
|
90
67
|
//# sourceMappingURL=cosigned.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosigned.js","sourceRoot":"","sources":["../../../../src/x402/wallets/smart-account/cosigned.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAoD,MAAM,MAAM,CAAA;AAC1G,OAAO,EAAE,mBA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CAAC,UAAU;YACxC,WAAW,EAAE,iBAAiB,CAAC,WAAW;YAC1C,KAAK,EAAE,iBAAiB,CAAC,KAAK;SAC/B;KACF,CAAA;IAED,OAAO,kBAAkB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAA;AACvD,CAAC"}
|
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
import { type Address, type Hex } from "viem";
|
|
2
|
-
import type
|
|
3
|
-
/**
|
|
4
|
-
* Configuration for creating an exact payment with ERC-3009
|
|
5
|
-
*/
|
|
2
|
+
import { type PaymentAuthorization, type PaymentInstruction } from "../../envelopes.ts";
|
|
6
3
|
export interface ExactPaymentConfig {
|
|
7
|
-
/** Smart account address (payment sender) */
|
|
8
4
|
smartAccountAddress: Address;
|
|
9
|
-
/** Session key private key for signing */
|
|
10
5
|
sessionKeyPrivateKey: Hex;
|
|
11
|
-
/**
|
|
12
|
-
chainId: number;
|
|
13
|
-
/** OwnableValidator address for ERC-1271 validation */
|
|
6
|
+
/** OwnableValidator address used for ERC-1271 validation. */
|
|
14
7
|
validatorAddress: Address;
|
|
15
8
|
}
|
|
16
9
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* (ERC-3009) to create signed payment authorizations. The signature is created using ERC-1271
|
|
21
|
-
* from a smart account via the OwnableValidator module.
|
|
22
|
-
*
|
|
23
|
-
* @param requirements - Payment requirements from the x402 server
|
|
24
|
-
* @param config - Configuration for the smart account wallet
|
|
25
|
-
* @returns Payment payload ready to send to x402 server
|
|
26
|
-
* @throws Error if payment requirements are invalid or signing fails
|
|
10
|
+
* Sign an `exact` instruction: ERC-3009 `transferWithAuthorization` via
|
|
11
|
+
* ERC-1271 with OwnableValidator. {@link buildAuthorization} packages the
|
|
12
|
+
* signed body for v1 or v2.
|
|
27
13
|
*/
|
|
28
|
-
export declare function createExactPayment(
|
|
14
|
+
export declare function createExactPayment(instruction: PaymentInstruction, config: ExactPaymentConfig): Promise<PaymentAuthorization>;
|
|
29
15
|
//# sourceMappingURL=exact.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exact.d.ts","sourceRoot":"","sources":["../../../../src/x402/wallets/smart-account/exact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"exact.d.ts","sourceRoot":"","sources":["../../../../src/x402/wallets/smart-account/exact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAA;AAGpD,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAA;AAa3B,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,EAAE,OAAO,CAAA;IAC5B,oBAAoB,EAAE,GAAG,CAAA;IACzB,6DAA6D;IAC7D,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,kBAAkB,EAC/B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,oBAAoB,CAAC,CAuD/B"}
|