@atumlabs/mppx-atum-escrow 0.3.0 → 0.4.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/CHANGELOG.md +31 -0
- package/README.md +85 -9
- package/THIRD-PARTY-NOTICES.txt +7 -0
- package/dist/{chunk-ZFA5SSUP.js → chunk-KRSFEITH.js} +3364 -409
- package/dist/{chunk-Z3AUNEU5.js → chunk-OEEC5P3E.js} +1295 -282
- package/dist/{chunk-4YD6566T.js → chunk-TPLD2L6B.js} +17 -7
- package/dist/client.d.ts +180 -42
- package/dist/client.js +9 -4
- package/dist/index.d.ts +3 -77
- package/dist/index.js +10 -5
- package/dist/{internal-9tB7y-A7.d.ts → internal-CJEu9yUF.d.ts} +113 -24
- package/dist/server.d.ts +38 -42
- package/dist/server.js +2 -2
- package/package.json +10 -8
|
@@ -11,8 +11,9 @@ import {
|
|
|
11
11
|
intentIdOf,
|
|
12
12
|
namespaceOf,
|
|
13
13
|
require_dist2 as require_dist,
|
|
14
|
-
sameAddress
|
|
15
|
-
|
|
14
|
+
sameAddress,
|
|
15
|
+
sameAssetIdentifier
|
|
16
|
+
} from "./chunk-OEEC5P3E.js";
|
|
16
17
|
|
|
17
18
|
// src/server.ts
|
|
18
19
|
var import_payment_request_sender_auth2 = __toESM(require_dist(), 1);
|
|
@@ -156,8 +157,7 @@ function registerServer(config) {
|
|
|
156
157
|
throw new Error("atum-escrow: destination account does not match the challenge");
|
|
157
158
|
}
|
|
158
159
|
const expectedDestAsset = assetIdentifier(extra.destination.network, extra.destination.asset);
|
|
159
|
-
|
|
160
|
-
if (!destAssetMatches) {
|
|
160
|
+
if (!sameAssetIdentifier(dest.asset_identifier, expectedDestAsset)) {
|
|
161
161
|
throw new Error("atum-escrow: destination asset does not match the challenge");
|
|
162
162
|
}
|
|
163
163
|
if (pr.fulfillment_amount !== extra.fulfillmentAmount) {
|
|
@@ -179,7 +179,9 @@ function registerServer(config) {
|
|
|
179
179
|
throw new Error("atum-escrow: fulfillment_proxy does not match the challenge");
|
|
180
180
|
}
|
|
181
181
|
if (!sameAddress(pr.fulfillment_verifier?.account ?? "", expectedVerifier.account)) {
|
|
182
|
-
throw new Error(
|
|
182
|
+
throw new Error(
|
|
183
|
+
"atum-escrow: fulfillment_verifier.account does not match the challenge releaser"
|
|
184
|
+
);
|
|
183
185
|
}
|
|
184
186
|
if ((pr.fulfillment_verifier?.endpoint ?? "") !== expectedVerifier.endpoint) {
|
|
185
187
|
throw new Error("atum-escrow: fulfillment_verifier.endpoint does not match the challenge");
|
|
@@ -247,13 +249,21 @@ function validateCorridor(corridor) {
|
|
|
247
249
|
throw new Error("atum-escrow: corridor must configure at least one source");
|
|
248
250
|
}
|
|
249
251
|
for (const src of corridor.sources) {
|
|
250
|
-
for (const field of [
|
|
252
|
+
for (const field of [
|
|
253
|
+
"network",
|
|
254
|
+
"escrow",
|
|
255
|
+
"reserver",
|
|
256
|
+
"releaser",
|
|
257
|
+
"fulfillmentVerifierEndpoint"
|
|
258
|
+
]) {
|
|
251
259
|
if (!src[field]) {
|
|
252
260
|
throw new Error(`atum-escrow: source ${src.network ?? "?"} is missing '${field}'`);
|
|
253
261
|
}
|
|
254
262
|
}
|
|
255
263
|
if (!src.assets || src.assets.length === 0 || src.assets.some((a) => !a)) {
|
|
256
|
-
throw new Error(
|
|
264
|
+
throw new Error(
|
|
265
|
+
`atum-escrow: source ${src.network} must list at least one non-empty asset in 'assets'`
|
|
266
|
+
);
|
|
257
267
|
}
|
|
258
268
|
if (namespaceOf(src.network) === "tron") {
|
|
259
269
|
(0, import_payment_request_sender_auth.resolveTronPermit2)(src.network);
|
package/dist/client.d.ts
CHANGED
|
@@ -1,11 +1,187 @@
|
|
|
1
1
|
import * as zod_v4_core from 'zod/v4/core';
|
|
2
2
|
import * as z from 'zod/mini';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, C as ChargeCredentialPayload, c as ChargeRequest, d as ChargeRequestSchema, e as CredentialPayloadSchema, I as INTENT, f as INTENT_ID_META_KEY, M as METHOD_NAME, h as atumEscrowChargeMethod } from './internal-9tB7y-A7.js';
|
|
3
|
+
import { S as SenderSigner, h as SenderSignerOptions, k as SolanaClusterUnixTimeReader } from './internal-CJEu9yUF.js';
|
|
4
|
+
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, C as ChargeCredentialPayload, d as ChargeRequest, e as ChargeRequestSchema, f as CredentialPayloadSchema, I as INTENT, g as INTENT_ID_META_KEY, M as METHOD_NAME, i as atumEscrowChargeMethod } from './internal-CJEu9yUF.js';
|
|
6
5
|
import { Method } from 'mppx';
|
|
6
|
+
import { Signer } from 'ethers';
|
|
7
7
|
export { PaymentRequest } from './generated/index.js';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Result of an {@link ensureSourceApproval} call.
|
|
11
|
+
*/
|
|
12
|
+
interface EnsureApprovalResult {
|
|
13
|
+
/** The existing allowance already covered the requirement; no transaction was sent. */
|
|
14
|
+
alreadySufficient: boolean;
|
|
15
|
+
/** The approval transaction hash, when one was sent. */
|
|
16
|
+
txHash?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Set only when the token refused to overwrite a non-zero allowance and it had to be reset to
|
|
19
|
+
* zero first: the hash of that reset. Its absence means one transaction was sent, not two.
|
|
20
|
+
*/
|
|
21
|
+
resetTxHash?: string;
|
|
22
|
+
}
|
|
23
|
+
/** What TronWeb reports about a broadcast transaction. Empty until it is confirmed. */
|
|
24
|
+
interface TronTransactionInfo {
|
|
25
|
+
receipt?: {
|
|
26
|
+
result?: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The slice of a TronWeb instance this package needs.
|
|
31
|
+
*
|
|
32
|
+
* Declared structurally rather than imported from `tronweb` on purpose: the package then
|
|
33
|
+
* type-checks and builds with tronweb absent, and consumers that never pay from Tron do not
|
|
34
|
+
* carry an 11 MB dependency they cannot reach. The caller constructs the instance and passes
|
|
35
|
+
* it in, exactly as the EVM path takes a caller-constructed ethers signer.
|
|
36
|
+
*/
|
|
37
|
+
interface TronWebLike {
|
|
38
|
+
/**
|
|
39
|
+
* The ABI-and-address form, which builds the handle locally. The `contract().at(address)`
|
|
40
|
+
* form fetches the ABI from the node instead: a round trip per use, and an interface that
|
|
41
|
+
* depends on what the chain happens to report for that address.
|
|
42
|
+
*
|
|
43
|
+
* Returns `unknown` on purpose. TronWeb types this as a contract whose methods are produced
|
|
44
|
+
* dynamically from the ABI, so pinning it to {@link TronTokenContract} here would stop a real
|
|
45
|
+
* TronWeb instance assigning to this interface at all and force every caller to write a cast.
|
|
46
|
+
* The cast belongs in one place — next to the ABI we passed, which is what makes it true.
|
|
47
|
+
*/
|
|
48
|
+
contract(abi: unknown, address: string): unknown;
|
|
49
|
+
trx: {
|
|
50
|
+
getTransactionInfo(txId: string): Promise<TronTransactionInfo>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The account this instance signs as. Read to check it against `owner` before broadcasting,
|
|
54
|
+
* since an approval only ever applies to the account that sends it.
|
|
55
|
+
*
|
|
56
|
+
* Optional, and `false` is TronWeb's own "not set": both mean the instance cannot say which
|
|
57
|
+
* account it would use, and neither is treated as a mismatch.
|
|
58
|
+
*/
|
|
59
|
+
defaultAddress?: {
|
|
60
|
+
base58?: string | false;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** How long to wait for a broadcast approval to confirm before giving up, on either chain. */
|
|
64
|
+
interface ConfirmationOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Default 60_000. On timeout the approval is reported as unconfirmed rather than failed: it
|
|
67
|
+
* was broadcast and may still confirm, so the caller is told to check it before sending
|
|
68
|
+
* another one.
|
|
69
|
+
*/
|
|
70
|
+
timeoutMs?: number;
|
|
71
|
+
/** Tron only: how often to poll for the receipt. Default 1_500, under Tron's ~3s block time. */
|
|
72
|
+
pollIntervalMs?: number;
|
|
73
|
+
/** Tron only: default 100_000_000 SUN. Tron charges the caller for contract execution. */
|
|
74
|
+
feeLimit?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Inputs to {@link ensureSourceApproval} and {@link needsSourceApproval}.
|
|
78
|
+
*
|
|
79
|
+
* `signer` and `tronWeb` are both optional here because which one is required is decided by
|
|
80
|
+
* `network`, a runtime string that no type can constrain. Supplying the wrong one for the
|
|
81
|
+
* chain fails with a message naming the one that was needed.
|
|
82
|
+
*/
|
|
83
|
+
interface ApprovalParams {
|
|
84
|
+
/** CAIP-2 source chain id, e.g. `eip155:8453` or `tron:mainnet`. */
|
|
85
|
+
network: string;
|
|
86
|
+
/** Source token address. */
|
|
87
|
+
token: string;
|
|
88
|
+
/** The payer's account. */
|
|
89
|
+
owner: string;
|
|
90
|
+
/**
|
|
91
|
+
* The contract to approve. Defaults to the canonical Permit2 for the chain: the EVM
|
|
92
|
+
* deployment on `eip155:*`, and the pinned per-network address on `tron:*`.
|
|
93
|
+
*/
|
|
94
|
+
spender?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The minimum allowance this charge needs. Answers "is what I already have enough?".
|
|
97
|
+
* When omitted, only an unlimited approval counts as sufficient, so a smaller leftover
|
|
98
|
+
* allowance cannot be mistaken for enough and revert a larger later charge on-chain.
|
|
99
|
+
*/
|
|
100
|
+
requiredAllowance?: bigint;
|
|
101
|
+
/**
|
|
102
|
+
* How much to approve when an approval IS sent. Defaults to unlimited, so later charges on
|
|
103
|
+
* the same token need no further transaction.
|
|
104
|
+
*
|
|
105
|
+
* On its own, a bounded amount is treated as its own requirement: an allowance still holding
|
|
106
|
+
* the full bound is left alone rather than re-approved. That is the right answer for a one-off
|
|
107
|
+
* approval, where nothing else in the call says what a later charge would need.
|
|
108
|
+
*
|
|
109
|
+
* Across repeated payments, PAIR IT WITH `requiredAllowance`. Permit2 decrements the allowance
|
|
110
|
+
* on every payment, so a bound measured against itself stops being sufficient the moment the
|
|
111
|
+
* first charge lands, and every later call sends another approval. `requiredAllowance` states
|
|
112
|
+
* what the NEXT charge needs, which is the question a partly spent bound can still answer yes
|
|
113
|
+
* to.
|
|
114
|
+
*
|
|
115
|
+
* Trade-off: a bounded approval limits what the escrow can ever move, but it is consumed as it
|
|
116
|
+
* is spent and eventually has to be granted again, whichever way it is used.
|
|
117
|
+
*/
|
|
118
|
+
approvalAmount?: bigint;
|
|
119
|
+
/** An ethers signer connected to the source chain. Required for `eip155:*`. */
|
|
120
|
+
signer?: Signer;
|
|
121
|
+
/** A TronWeb instance configured for the source chain. Required for `tron:*`. */
|
|
122
|
+
tronWeb?: TronWebLike;
|
|
123
|
+
/** Broadcast and confirmation tuning. Applies to both chains. */
|
|
124
|
+
confirmation?: ConfirmationOptions;
|
|
125
|
+
/**
|
|
126
|
+
* Called with each transaction hash the moment it is broadcast, before the wait for it to
|
|
127
|
+
* confirm. Without this a caller has nothing to show for a transaction that is already
|
|
128
|
+
* spending their gas — and nothing to look up if the wait times out.
|
|
129
|
+
*
|
|
130
|
+
* `purpose` distinguishes the approval itself from the zero-reset some tokens demand first,
|
|
131
|
+
* so two hashes in one call read as one deliberate sequence rather than a double spend.
|
|
132
|
+
*/
|
|
133
|
+
onSubmitted?: (txHash: string, purpose: "approval" | "reset") => void;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Whether an error came from a broadcast transaction that was never seen to confirm. */
|
|
137
|
+
declare function isUnconfirmed(error: unknown): boolean;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Payer-side Permit2 approval for the source token an escrow deposit moves.
|
|
141
|
+
*
|
|
142
|
+
* On EVM and Tron the escrow moves the source token through Permit2, so the payer must have
|
|
143
|
+
* approved Permit2 on that token BEFORE paying. Without it the payment is built, signed and
|
|
144
|
+
* accepted by the gateway, and then the deposit reverts on-chain at settlement — a late and
|
|
145
|
+
* misleading failure. Solana authorizes the transfer inside the signed deposit itself, so
|
|
146
|
+
* there is nothing to approve there.
|
|
147
|
+
*
|
|
148
|
+
* Worth arranging before the payment is signed: a deposit that reverts is a terminal
|
|
149
|
+
* settlement failure, and a terminal failure is bound to the request identifier that produced
|
|
150
|
+
* it, so re-attempting then needs a NEW identifier. Getting the allowance right up front keeps
|
|
151
|
+
* the identifier usable.
|
|
152
|
+
*
|
|
153
|
+
* This package reads chain state and broadcasts a transaction, which is why it is separate
|
|
154
|
+
* from the sender-auth SDK next door: that one is pure, offline and byte-parity-tested against
|
|
155
|
+
* Go. The caller supplies the connected signer, so this package never chooses an RPC endpoint.
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Whether a payment on these terms would need an approval transaction first.
|
|
160
|
+
*
|
|
161
|
+
* Read-only: it spends no gas and sends nothing, so it is safe to call on every payment as a
|
|
162
|
+
* preflight. Returns false on Solana, which needs no approval at all.
|
|
163
|
+
*
|
|
164
|
+
* @remarks
|
|
165
|
+
* Unlike a try-and-see, this reports the answer instead of acting on it — use it to tell a
|
|
166
|
+
* payer what is about to happen, or to check whether a wallet is ready before asking for a
|
|
167
|
+
* signature.
|
|
168
|
+
*/
|
|
169
|
+
declare function needsSourceApproval(params: ApprovalParams): Promise<boolean>;
|
|
170
|
+
/**
|
|
171
|
+
* Ensure the payer has approved Permit2 to move the source token, so the escrow deposit does
|
|
172
|
+
* not revert at settlement. Reads the current allowance and sends an approval only if it falls
|
|
173
|
+
* short; the approval it sends is unlimited unless `approvalAmount` bounds it.
|
|
174
|
+
*
|
|
175
|
+
* Applies to EVM (`params.signer`) and Tron (`params.tronWeb`). On Solana it reports
|
|
176
|
+
* `alreadySufficient` without touching the chain.
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* Not concurrency-safe: two overlapping calls for the same `(owner, token, spender)` may both
|
|
180
|
+
* read a short allowance and both send an approval. They target the same value, so this only
|
|
181
|
+
* wastes gas; serialize calls per token if that matters.
|
|
182
|
+
*/
|
|
183
|
+
declare function ensureSourceApproval(params: ApprovalParams): Promise<EnsureApprovalResult>;
|
|
184
|
+
|
|
9
185
|
/** Configuration for the payer side of the method. */
|
|
10
186
|
interface AtumEscrowClientConfig {
|
|
11
187
|
/**
|
|
@@ -89,43 +265,5 @@ declare function registerClient(config: AtumEscrowClientConfig): Method.Client<{
|
|
|
89
265
|
};
|
|
90
266
|
};
|
|
91
267
|
}, undefined>;
|
|
92
|
-
/** Result of an {@link ensureSourceApproval} call. */
|
|
93
|
-
interface EnsureApprovalResult {
|
|
94
|
-
/** The existing allowance already covered the required amount; no transaction was sent. */
|
|
95
|
-
alreadySufficient: boolean;
|
|
96
|
-
/** The approval transaction hash, when one was sent. */
|
|
97
|
-
txHash?: string;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Ensure the payer has approved the token-transfer contract (Permit2) to move the source
|
|
101
|
-
* token, so the escrow deposit does not revert at settlement. Reads the current allowance
|
|
102
|
-
* and sends an approval only if it falls short.
|
|
103
|
-
*
|
|
104
|
-
* Applies to EVM and Tron sources (which use a Permit2-style allowance); Solana sources
|
|
105
|
-
* authorize the transfer in the signed deposit itself, so this is a no-op there.
|
|
106
|
-
*
|
|
107
|
-
* @param params.network - CAIP-2 source chain id.
|
|
108
|
-
* @param params.token - source token address.
|
|
109
|
-
* @param params.owner - the payer's account.
|
|
110
|
-
* @param params.signer - an ethers signer able to send the approval on `network`.
|
|
111
|
-
* @param params.spender - the contract to approve; defaults to the canonical EVM Permit2.
|
|
112
|
-
* Required for Tron (its Permit2 address is chain-specific).
|
|
113
|
-
* @param params.requiredAllowance - the minimum allowance this charge needs (pass the
|
|
114
|
-
* source cap, `challenge.request.source.amount`). When omitted, the function ensures an
|
|
115
|
-
* unlimited approval — a smaller leftover allowance is NOT treated as sufficient, so a
|
|
116
|
-
* later larger charge cannot slip through and revert on-chain.
|
|
117
|
-
*
|
|
118
|
-
* Not concurrency-safe: two overlapping calls for the same `(owner, token, spender)` may
|
|
119
|
-
* both read a short allowance and both send an approval. They target the same value, so
|
|
120
|
-
* this only wastes gas; serialize calls per token if that matters.
|
|
121
|
-
*/
|
|
122
|
-
declare function ensureSourceApproval(params: {
|
|
123
|
-
network: string;
|
|
124
|
-
token: string;
|
|
125
|
-
owner: string;
|
|
126
|
-
signer: Signer;
|
|
127
|
-
spender?: string;
|
|
128
|
-
requiredAllowance?: bigint;
|
|
129
|
-
}): Promise<EnsureApprovalResult>;
|
|
130
268
|
|
|
131
|
-
export { type AtumEscrowClientConfig, type EnsureApprovalResult, SenderSigner, SenderSignerOptions, ensureSourceApproval, registerClient };
|
|
269
|
+
export { type ApprovalParams, type AtumEscrowClientConfig, type ConfirmationOptions, type EnsureApprovalResult, SenderSigner, SenderSignerOptions, type TronWebLike, ensureSourceApproval, isUnconfirmed, needsSourceApproval, registerClient };
|
package/dist/client.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { createRequire as __atumCreateRequire } from 'module'; const require = __atumCreateRequire(import.meta.url);
|
|
8
8
|
import {
|
|
9
|
-
|
|
9
|
+
import_payment_request_token_approval,
|
|
10
10
|
registerClient
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-KRSFEITH.js";
|
|
12
12
|
import {
|
|
13
13
|
ChargeRequestSchema,
|
|
14
14
|
CredentialPayloadSchema,
|
|
@@ -16,7 +16,10 @@ import {
|
|
|
16
16
|
INTENT_ID_META_KEY,
|
|
17
17
|
METHOD_NAME,
|
|
18
18
|
atumEscrowChargeMethod
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-OEEC5P3E.js";
|
|
20
|
+
var export_ensureSourceApproval = import_payment_request_token_approval.ensureSourceApproval;
|
|
21
|
+
var export_isUnconfirmed = import_payment_request_token_approval.isUnconfirmed;
|
|
22
|
+
var export_needsSourceApproval = import_payment_request_token_approval.needsSourceApproval;
|
|
20
23
|
export {
|
|
21
24
|
ChargeRequestSchema,
|
|
22
25
|
CredentialPayloadSchema,
|
|
@@ -24,6 +27,8 @@ export {
|
|
|
24
27
|
INTENT_ID_META_KEY,
|
|
25
28
|
METHOD_NAME,
|
|
26
29
|
atumEscrowChargeMethod,
|
|
27
|
-
ensureSourceApproval,
|
|
30
|
+
export_ensureSourceApproval as ensureSourceApproval,
|
|
31
|
+
export_isUnconfirmed as isUnconfirmed,
|
|
32
|
+
export_needsSourceApproval as needsSourceApproval,
|
|
28
33
|
registerClient
|
|
29
34
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,82 +1,8 @@
|
|
|
1
|
-
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, b as AtumEscrowRequest, C as ChargeCredentialPayload,
|
|
2
|
-
export { AtumEscrowClientConfig, EnsureApprovalResult, ensureSourceApproval, registerClient } from './client.js';
|
|
3
|
-
export { AtumEscrowCorridor, AtumEscrowReceipt, AtumEscrowServerConfig, AtumEscrowSource, ChainDefaultsSource, ChargeChallenge, FulfillmentConfirmation, PaymentRejectedError, PaymentSettlementStatus, PaymentSubmitResult, PaymentSubmitter, SettlementErrorDetails, SettlementFailedError, SettlementPendingError, buildChargeChallenge, buildChargeRequest, corridorFromDefaults, isPaymentRejected, isSettlementFailed, isSettlementPending, registerServer, validateCorridor } from './server.js';
|
|
1
|
+
export { A as AtumEscrowChallenge, a as AtumEscrowCredential, b as AtumEscrowExtra, c as AtumEscrowRequest, C as ChargeCredentialPayload, d as ChargeRequest, e as ChargeRequestSchema, f as CredentialPayloadSchema, I as INTENT, g as INTENT_ID_META_KEY, M as METHOD_NAME, S as SenderSigner, h as SenderSignerOptions, i as atumEscrowChargeMethod } from './internal-CJEu9yUF.js';
|
|
2
|
+
export { ApprovalParams, AtumEscrowClientConfig, ConfirmationOptions, EnsureApprovalResult, TronWebLike, ensureSourceApproval, isUnconfirmed, needsSourceApproval, registerClient } from './client.js';
|
|
3
|
+
export { AtumEscrowCorridor, AtumEscrowReceipt, AtumEscrowServer, AtumEscrowServerConfig, AtumEscrowSource, ChainDefaultsSource, ChargeChallenge, FulfillmentConfirmation, PaymentRejectedError, PaymentSettlementStatus, PaymentSubmitResult, PaymentSubmitter, SettlementErrorDetails, SettlementFailedError, SettlementPendingError, buildChargeChallenge, buildChargeRequest, corridorFromDefaults, isPaymentRejected, isSettlementFailed, isSettlementPending, registerServer, validateCorridor } from './server.js';
|
|
4
4
|
export { PaymentRequest } from './generated/index.js';
|
|
5
5
|
import 'zod/mini';
|
|
6
6
|
import 'mppx';
|
|
7
7
|
import 'zod/v4/core';
|
|
8
8
|
import 'ethers';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
12
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
13
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* The `extra.atum` object carried inside an atum-escrow x402 PaymentRequirements entry (accepts[]): the merchant's receive-side plus the contract/role addresses and deadline budgets. Scheme-specific data the standard x402 `extra` bag treats as opaque, so it is owned here and shared by all role mechanisms. Addresses are chain-general: an EVM `0x`-hex address (20 bytes) or a base58-encoded address (Solana/Tron), per the field's CAIP-2 chain.
|
|
17
|
-
*/
|
|
18
|
-
interface AtumEscrowExtra {
|
|
19
|
-
/**
|
|
20
|
-
* Where the merchant receives (CAIP-2 chain, token, address).
|
|
21
|
-
*/
|
|
22
|
-
destination: {
|
|
23
|
-
/**
|
|
24
|
-
* CAIP-2 destination chain id (e.g. eip155:42161).
|
|
25
|
-
*/
|
|
26
|
-
network: string;
|
|
27
|
-
/**
|
|
28
|
-
* Destination token contract address (EVM hex or base58, per the destination chain).
|
|
29
|
-
*/
|
|
30
|
-
asset: string;
|
|
31
|
-
/**
|
|
32
|
-
* Merchant receive address (EVM hex or base58, per the destination chain).
|
|
33
|
-
*/
|
|
34
|
-
address: string;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Exact amount the merchant receives, in atomic token units.
|
|
38
|
-
*/
|
|
39
|
-
fulfillmentAmount: string;
|
|
40
|
-
/**
|
|
41
|
-
* Source-chain escrow contract (the x402 payTo); EVM hex or base58, per the source chain.
|
|
42
|
-
*/
|
|
43
|
-
escrow: string;
|
|
44
|
-
/**
|
|
45
|
-
* Destination-chain fulfillment proxy contract (EVM hex or base58, per the destination chain).
|
|
46
|
-
*/
|
|
47
|
-
fulfillmentProxy: string;
|
|
48
|
-
/**
|
|
49
|
-
* Atum reserver role address (escrow deposit witness); EVM hex or base58, per the source chain.
|
|
50
|
-
*/
|
|
51
|
-
reserver: string;
|
|
52
|
-
/**
|
|
53
|
-
* Atum releaser role address (escrow deposit witness); EVM hex or base58, per the source chain.
|
|
54
|
-
*/
|
|
55
|
-
releaser: string;
|
|
56
|
-
/**
|
|
57
|
-
* Source-chain fulfillment-verifier endpoint the payment request carries. The verifier account and the quote_selector are the releaser and reserver respectively (the network derives the deposit witness roles from them), so only the endpoint is not otherwise present in this object.
|
|
58
|
-
*/
|
|
59
|
-
fulfillmentVerifierEndpoint: string;
|
|
60
|
-
/**
|
|
61
|
-
* Recommended quote-deadline budget in seconds, relative to signing time.
|
|
62
|
-
*/
|
|
63
|
-
quoteDeadlineSeconds: number;
|
|
64
|
-
/**
|
|
65
|
-
* Recommended fulfillment-deadline budget in seconds, relative to signing time.
|
|
66
|
-
*/
|
|
67
|
-
fulfillmentDeadlineSeconds: number;
|
|
68
|
-
/**
|
|
69
|
-
* Solana source only: cluster name used to build the 32-byte cluster_id in the V3 escrow signature domain. Optional; the facilitator requires it for a Solana source.
|
|
70
|
-
*/
|
|
71
|
-
svmSignatureClusterId?: string;
|
|
72
|
-
/**
|
|
73
|
-
* Solana source only: escrow signature-domain version (V3 domain separation). Optional; required for a Solana source.
|
|
74
|
-
*/
|
|
75
|
-
svmSignatureDomainVersion?: number;
|
|
76
|
-
/**
|
|
77
|
-
* Solana source only: merchant-stamped issue time in epoch seconds. The merchant reads the cluster clock so the client makes no RPC and the 402 stays self-contained. Optional; required for a Solana source.
|
|
78
|
-
*/
|
|
79
|
-
issuedAt?: string;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export type { AtumEscrowExtra };
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { createRequire as __atumCreateRequire } from 'module'; const require = __atumCreateRequire(import.meta.url);
|
|
8
8
|
import {
|
|
9
|
-
|
|
9
|
+
import_payment_request_token_approval,
|
|
10
10
|
registerClient
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-KRSFEITH.js";
|
|
12
12
|
import {
|
|
13
13
|
PaymentRejectedError,
|
|
14
14
|
SettlementFailedError,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
isSettlementPending,
|
|
22
22
|
registerServer,
|
|
23
23
|
validateCorridor
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-TPLD2L6B.js";
|
|
25
25
|
import {
|
|
26
26
|
ChargeRequestSchema,
|
|
27
27
|
CredentialPayloadSchema,
|
|
@@ -29,7 +29,10 @@ import {
|
|
|
29
29
|
INTENT_ID_META_KEY,
|
|
30
30
|
METHOD_NAME,
|
|
31
31
|
atumEscrowChargeMethod
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-OEEC5P3E.js";
|
|
33
|
+
var export_ensureSourceApproval = import_payment_request_token_approval.ensureSourceApproval;
|
|
34
|
+
var export_isUnconfirmed = import_payment_request_token_approval.isUnconfirmed;
|
|
35
|
+
var export_needsSourceApproval = import_payment_request_token_approval.needsSourceApproval;
|
|
33
36
|
export {
|
|
34
37
|
ChargeRequestSchema,
|
|
35
38
|
CredentialPayloadSchema,
|
|
@@ -43,10 +46,12 @@ export {
|
|
|
43
46
|
buildChargeChallenge,
|
|
44
47
|
buildChargeRequest,
|
|
45
48
|
corridorFromDefaults,
|
|
46
|
-
ensureSourceApproval,
|
|
49
|
+
export_ensureSourceApproval as ensureSourceApproval,
|
|
47
50
|
isPaymentRejected,
|
|
48
51
|
isSettlementFailed,
|
|
49
52
|
isSettlementPending,
|
|
53
|
+
export_isUnconfirmed as isUnconfirmed,
|
|
54
|
+
export_needsSourceApproval as needsSourceApproval,
|
|
50
55
|
registerClient,
|
|
51
56
|
registerServer,
|
|
52
57
|
validateCorridor
|