@integraledger/terms 0.1.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/LICENSE +202 -0
- package/README.md +539 -0
- package/dist/agreement.d.ts +23 -0
- package/dist/agreement.js +264 -0
- package/dist/channels.d.ts +49 -0
- package/dist/channels.js +395 -0
- package/dist/gate.d.ts +69 -0
- package/dist/gate.js +347 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/pairings/ack-payment-request.d.ts +1 -0
- package/dist/pairings/ack-payment-request.js +12 -0
- package/dist/pairings/acp-checkout-delegated.d.ts +2 -0
- package/dist/pairings/acp-checkout-delegated.js +28 -0
- package/dist/pairings/acp-checkout-undelegated.d.ts +1 -0
- package/dist/pairings/acp-checkout-undelegated.js +11 -0
- package/dist/pairings/ap2-checkout-mandate.d.ts +2 -0
- package/dist/pairings/ap2-checkout-mandate.js +23 -0
- package/dist/pairings/batch.d.ts +29 -0
- package/dist/pairings/batch.js +83 -0
- package/dist/pairings/card-mastercard-vi-autonomous.d.ts +1 -0
- package/dist/pairings/card-mastercard-vi-autonomous.js +3 -0
- package/dist/pairings/card-mastercard-vi-immediate.d.ts +1 -0
- package/dist/pairings/card-mastercard-vi-immediate.js +3 -0
- package/dist/pairings/card-seller-reference.d.ts +1 -0
- package/dist/pairings/card-seller-reference.js +3 -0
- package/dist/pairings/card-visa-tap.d.ts +1 -0
- package/dist/pairings/card-visa-tap.js +3 -0
- package/dist/pairings/card.d.ts +7 -0
- package/dist/pairings/card.js +68 -0
- package/dist/pairings/common.d.ts +54 -0
- package/dist/pairings/common.js +134 -0
- package/dist/pairings/evm-x402.d.ts +3 -0
- package/dist/pairings/evm-x402.js +49 -0
- package/dist/pairings/index.d.ts +3 -0
- package/dist/pairings/index.js +134 -0
- package/dist/pairings/lightning.d.ts +17 -0
- package/dist/pairings/lightning.js +112 -0
- package/dist/pairings/lnbtc-request.d.ts +24 -0
- package/dist/pairings/lnbtc-request.js +175 -0
- package/dist/pairings/mpp-charge-card.d.ts +1 -0
- package/dist/pairings/mpp-charge-card.js +3 -0
- package/dist/pairings/mpp-charge-evm-authorization.d.ts +1 -0
- package/dist/pairings/mpp-charge-evm-authorization.js +3 -0
- package/dist/pairings/mpp-charge-evm-hash.d.ts +1 -0
- package/dist/pairings/mpp-charge-evm-hash.js +3 -0
- package/dist/pairings/mpp-charge-evm-permit2.d.ts +1 -0
- package/dist/pairings/mpp-charge-evm-permit2.js +3 -0
- package/dist/pairings/mpp-charge-evm-transaction.d.ts +1 -0
- package/dist/pairings/mpp-charge-evm-transaction.js +3 -0
- package/dist/pairings/mpp-charge-hedera.d.ts +23 -0
- package/dist/pairings/mpp-charge-hedera.js +137 -0
- package/dist/pairings/mpp-charge-nearintents.d.ts +2 -0
- package/dist/pairings/mpp-charge-nearintents.js +19 -0
- package/dist/pairings/mpp-charge-solana.d.ts +1 -0
- package/dist/pairings/mpp-charge-solana.js +25 -0
- package/dist/pairings/mpp-charge-stellar.d.ts +1 -0
- package/dist/pairings/mpp-charge-stellar.js +16 -0
- package/dist/pairings/mpp-charge-stripe.d.ts +1 -0
- package/dist/pairings/mpp-charge-stripe.js +3 -0
- package/dist/pairings/mpp-charge-tempo-memo.d.ts +9 -0
- package/dist/pairings/mpp-charge-tempo-memo.js +10 -0
- package/dist/pairings/mpp-charge-tempo-push.d.ts +12 -0
- package/dist/pairings/mpp-charge-tempo-push.js +21 -0
- package/dist/pairings/mpp-charge-usdc-evm.d.ts +1 -0
- package/dist/pairings/mpp-charge-usdc-evm.js +6 -0
- package/dist/pairings/mpp-charge-usdc-gateway.d.ts +2 -0
- package/dist/pairings/mpp-charge-usdc-gateway.js +33 -0
- package/dist/pairings/mpp-charge-usdc-solana.d.ts +1 -0
- package/dist/pairings/mpp-charge-usdc-solana.js +25 -0
- package/dist/pairings/mpp-charge-usdc-stacks.d.ts +1 -0
- package/dist/pairings/mpp-charge-usdc-stacks.js +17 -0
- package/dist/pairings/mpp-charge-xrpl.d.ts +1 -0
- package/dist/pairings/mpp-charge-xrpl.js +20 -0
- package/dist/pairings/mpp-confirm-only.d.ts +2 -0
- package/dist/pairings/mpp-confirm-only.js +21 -0
- package/dist/pairings/mpp-rails.d.ts +48 -0
- package/dist/pairings/mpp-rails.js +71 -0
- package/dist/pairings/mpp-session-evm.d.ts +1 -0
- package/dist/pairings/mpp-session-evm.js +3 -0
- package/dist/pairings/mpp-session-hedera.d.ts +2 -0
- package/dist/pairings/mpp-session-hedera.js +41 -0
- package/dist/pairings/mpp-session-solana.d.ts +1 -0
- package/dist/pairings/mpp-session-solana.js +60 -0
- package/dist/pairings/mpp-session-tempo.d.ts +1 -0
- package/dist/pairings/mpp-session-tempo.js +3 -0
- package/dist/pairings/mpp-session-xrpl.d.ts +1 -0
- package/dist/pairings/mpp-session-xrpl.js +42 -0
- package/dist/pairings/mpp-session.d.ts +5 -0
- package/dist/pairings/mpp-session.js +65 -0
- package/dist/pairings/mpp-subscription-stripe.d.ts +1 -0
- package/dist/pairings/mpp-subscription-stripe.js +6 -0
- package/dist/pairings/mpp-subscription-tempo.d.ts +2 -0
- package/dist/pairings/mpp-subscription-tempo.js +2 -0
- package/dist/pairings/mpp.d.ts +43 -0
- package/dist/pairings/mpp.js +194 -0
- package/dist/pairings/protocol-groups.d.ts +17 -0
- package/dist/pairings/protocol-groups.js +27 -0
- package/dist/pairings/ucp-booking-ap2-mandate.d.ts +1 -0
- package/dist/pairings/ucp-booking-ap2-mandate.js +3 -0
- package/dist/pairings/ucp-booking-unsigned.d.ts +1 -0
- package/dist/pairings/ucp-booking-unsigned.js +3 -0
- package/dist/pairings/ucp-checkout-ap2-mandate.d.ts +1 -0
- package/dist/pairings/ucp-checkout-ap2-mandate.js +3 -0
- package/dist/pairings/ucp-checkout-unsigned.d.ts +1 -0
- package/dist/pairings/ucp-checkout-unsigned.js +3 -0
- package/dist/pairings/ucp.d.ts +5 -0
- package/dist/pairings/ucp.js +35 -0
- package/dist/pairings/x402-account-rails.d.ts +25 -0
- package/dist/pairings/x402-account-rails.js +52 -0
- package/dist/pairings/x402-auth-capture-eip155-eip3009.d.ts +1 -0
- package/dist/pairings/x402-auth-capture-eip155-eip3009.js +3 -0
- package/dist/pairings/x402-auth-capture-eip155-permit2.d.ts +1 -0
- package/dist/pairings/x402-auth-capture-eip155-permit2.js +3 -0
- package/dist/pairings/x402-batch-settlement-cloudflare.d.ts +2 -0
- package/dist/pairings/x402-batch-settlement-cloudflare.js +21 -0
- package/dist/pairings/x402-batch-settlement-eip155.d.ts +2 -0
- package/dist/pairings/x402-batch-settlement-eip155.js +32 -0
- package/dist/pairings/x402-batch-settlement-solana.d.ts +2 -0
- package/dist/pairings/x402-batch-settlement-solana.js +55 -0
- package/dist/pairings/x402-exact-algorand.d.ts +1 -0
- package/dist/pairings/x402-exact-algorand.js +37 -0
- package/dist/pairings/x402-exact-aptos.d.ts +1 -0
- package/dist/pairings/x402-exact-aptos.js +9 -0
- package/dist/pairings/x402-exact-cardano.d.ts +1 -0
- package/dist/pairings/x402-exact-cardano.js +7 -0
- package/dist/pairings/x402-exact-casper.d.ts +2 -0
- package/dist/pairings/x402-exact-casper.js +21 -0
- package/dist/pairings/x402-exact-ccd.d.ts +2 -0
- package/dist/pairings/x402-exact-ccd.js +20 -0
- package/dist/pairings/x402-exact-eip155-eip3009.d.ts +1 -0
- package/dist/pairings/x402-exact-eip155-eip3009.js +3 -0
- package/dist/pairings/x402-exact-eip155-erc7710-salt.d.ts +1 -0
- package/dist/pairings/x402-exact-eip155-erc7710-salt.js +3 -0
- package/dist/pairings/x402-exact-eip155-erc7710.d.ts +1 -0
- package/dist/pairings/x402-exact-eip155-erc7710.js +3 -0
- package/dist/pairings/x402-exact-eip155-permit2.d.ts +1 -0
- package/dist/pairings/x402-exact-eip155-permit2.js +3 -0
- package/dist/pairings/x402-exact-hedera-transfer-executor.d.ts +1 -0
- package/dist/pairings/x402-exact-hedera-transfer-executor.js +23 -0
- package/dist/pairings/x402-exact-hedera.d.ts +3 -0
- package/dist/pairings/x402-exact-hedera.js +46 -0
- package/dist/pairings/x402-exact-near.d.ts +2 -0
- package/dist/pairings/x402-exact-near.js +34 -0
- package/dist/pairings/x402-exact-polkadot-lcp-assets-remark.d.ts +2 -0
- package/dist/pairings/x402-exact-polkadot-lcp-assets-remark.js +20 -0
- package/dist/pairings/x402-exact-solana.d.ts +11 -0
- package/dist/pairings/x402-exact-solana.js +36 -0
- package/dist/pairings/x402-exact-starknet.d.ts +2 -0
- package/dist/pairings/x402-exact-starknet.js +20 -0
- package/dist/pairings/x402-exact-stellar.d.ts +1 -0
- package/dist/pairings/x402-exact-stellar.js +17 -0
- package/dist/pairings/x402-exact-sui.d.ts +1 -0
- package/dist/pairings/x402-exact-sui.js +10 -0
- package/dist/pairings/x402-exact-tron-lcp-trc20-memo.d.ts +2 -0
- package/dist/pairings/x402-exact-tron-lcp-trc20-memo.js +45 -0
- package/dist/pairings/x402-exact-tvm.d.ts +2 -0
- package/dist/pairings/x402-exact-tvm.js +35 -0
- package/dist/pairings/x402-exact-xrpl.d.ts +1 -0
- package/dist/pairings/x402-exact-xrpl.js +27 -0
- package/dist/pairings/x402-rail.d.ts +31 -0
- package/dist/pairings/x402-rail.js +65 -0
- package/dist/pairings/x402-upto-eip155-permit2.d.ts +1 -0
- package/dist/pairings/x402-upto-eip155-permit2.js +3 -0
- package/dist/pairings/x402-upto-solana.d.ts +1 -0
- package/dist/pairings/x402-upto-solana.js +42 -0
- package/dist/transact.d.ts +20 -0
- package/dist/transact.js +53 -0
- package/dist/types.d.ts +169 -0
- package/dist/types.js +2 -0
- package/package.json +64 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* x402 `lnbtc`'s request binding, computed by the buyer from its own request: the option's profile and parameters are
|
|
3
|
+
* validated, the binding object is built from the request the buyer gives, and `requestHash` is SHA-256 over the UTF-8
|
|
4
|
+
* of its RFC 8785 form. The option's `extra.requestHash` and the invoice's description hash must both equal it.
|
|
5
|
+
*
|
|
6
|
+
* The buyer's request, the `request` input:
|
|
7
|
+
* - `http:1`: `{method, url, body?, headers?}`, `body` the content bytes as `0x` hex (absent is empty), `headers` the
|
|
8
|
+
* value of each present header by lower-case name, each field line's values joined as RFC 9421 §2.1 joins them.
|
|
9
|
+
* - `mcp:1`: `{server, name, arguments?, meta?}`, `server` the MCP server's URI as the buyer's own configuration spells
|
|
10
|
+
* it, `name` and `arguments` the `tools/call` params, `meta` its `params._meta`.
|
|
11
|
+
*/
|
|
12
|
+
import { canonicalJson, hash } from "@integraledger/lcp";
|
|
13
|
+
import { decodeBolt11, invoiceH } from "@integraledger/lcp/lightning";
|
|
14
|
+
import { bytesOf, isObject, isRefusal, refuse } from "./common.js";
|
|
15
|
+
const HTTP_DOMAIN = "x402:exact:lnbtc:bolt11:http:1";
|
|
16
|
+
const MCP_DOMAIN = "x402:exact:lnbtc:bolt11:mcp:1";
|
|
17
|
+
const REQUEST_HASH = /^[0-9a-f]{64}$/;
|
|
18
|
+
const FIELD_NAME = /^[!#$%&'*+.^_`|~0-9a-z-]+$/;
|
|
19
|
+
const METHOD = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
20
|
+
const FIELD_VALUE = /^[\t\x20-\x7e]*$/;
|
|
21
|
+
const ASCII_URI = /^[\x21-\x7e]+$/;
|
|
22
|
+
/** `http` or `https`, `//`, an authority with no user information, then a path or query and no fragment. */
|
|
23
|
+
const HTTP_TARGET = /^https?:\/\/[^/?#@]+(?:[/?][^#]*)?$/i;
|
|
24
|
+
/** A scheme, then no fragment; where there is an authority, no user information in it. */
|
|
25
|
+
const ABSOLUTE_URI = /^[A-Za-z][A-Za-z0-9+.-]*:[^#]*$/;
|
|
26
|
+
const USERINFO = /^[A-Za-z][A-Za-z0-9+.-]*:\/\/[^/?#]*@/;
|
|
27
|
+
const EXCLUDED_META = ["x402/payment", "progressToken"];
|
|
28
|
+
const malformed = () => refuse("ln/request-binding-malformed");
|
|
29
|
+
function exactKeys(o, keys) {
|
|
30
|
+
const own = Object.keys(o);
|
|
31
|
+
return own.length === keys.length && keys.every((k) => Object.hasOwn(o, k));
|
|
32
|
+
}
|
|
33
|
+
/** Lower-case hex of SHA-256 over `bytes`. */
|
|
34
|
+
async function sha256Hex(bytes) {
|
|
35
|
+
return (await hash(bytes)).slice(2);
|
|
36
|
+
}
|
|
37
|
+
/** SHA-256 of `0x01 || bytes` for a present value, of the single byte `0x00` for an absent one. */
|
|
38
|
+
async function valueHash(bytes) {
|
|
39
|
+
if (bytes === undefined)
|
|
40
|
+
return sha256Hex(Uint8Array.of(0x00));
|
|
41
|
+
const b = new Uint8Array(bytes.length + 1);
|
|
42
|
+
b[0] = 0x01;
|
|
43
|
+
b.set(bytes, 1);
|
|
44
|
+
return sha256Hex(b);
|
|
45
|
+
}
|
|
46
|
+
/** An absolute `http` or `https` URL in ASCII syntax, with a host, and no fragment or user information. */
|
|
47
|
+
function isTargetUri(url) {
|
|
48
|
+
return typeof url === "string" && ASCII_URI.test(url) && HTTP_TARGET.test(url) && URL.canParse(url);
|
|
49
|
+
}
|
|
50
|
+
/** Strictly ascending and without duplicates, by UTF-16 code units, which is RFC 8785's member order. */
|
|
51
|
+
function ascending(names) {
|
|
52
|
+
for (let i = 1; i < names.length; i++)
|
|
53
|
+
if (!(names[i - 1] < names[i]))
|
|
54
|
+
return false;
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
async function httpBinding(params, request, resourceUrl) {
|
|
58
|
+
if (!exactKeys(params, ["headers"]) || !Array.isArray(params["headers"]))
|
|
59
|
+
return malformed();
|
|
60
|
+
const names = params["headers"];
|
|
61
|
+
if (!names.every((n) => typeof n === "string" && FIELD_NAME.test(n) && n !== "payment-signature"))
|
|
62
|
+
return malformed();
|
|
63
|
+
if (!ascending(names))
|
|
64
|
+
return malformed();
|
|
65
|
+
const { method, url, body, headers } = request;
|
|
66
|
+
if (typeof method !== "string" || !METHOD.test(method) || !isTargetUri(url))
|
|
67
|
+
return malformed();
|
|
68
|
+
if (resourceUrl !== url)
|
|
69
|
+
return refuse("ln/request-resource-mismatch");
|
|
70
|
+
const content = body === undefined ? new Uint8Array(0) : bytesOf(body);
|
|
71
|
+
if (content === undefined)
|
|
72
|
+
return malformed();
|
|
73
|
+
if (headers !== undefined && !isObject(headers))
|
|
74
|
+
return malformed();
|
|
75
|
+
const given = (headers ?? {});
|
|
76
|
+
const bound = [];
|
|
77
|
+
for (const name of names) {
|
|
78
|
+
const v = Object.hasOwn(given, name) ? given[name] : undefined;
|
|
79
|
+
if (v !== undefined && (typeof v !== "string" || !FIELD_VALUE.test(v)))
|
|
80
|
+
return malformed();
|
|
81
|
+
const value = v === undefined ? undefined : new TextEncoder().encode(v.replace(/^[\t ]+|[\t ]+$/g, ""));
|
|
82
|
+
bound.push({ name, valueHash: await valueHash(value) });
|
|
83
|
+
}
|
|
84
|
+
return { domain: HTTP_DOMAIN, method, url, bodyHash: await sha256Hex(content), headers: bound };
|
|
85
|
+
}
|
|
86
|
+
async function mcpBinding(params, request) {
|
|
87
|
+
if (!exactKeys(params, ["server", "metadata"]) || !Array.isArray(params["metadata"]))
|
|
88
|
+
return malformed();
|
|
89
|
+
const names = params["metadata"];
|
|
90
|
+
if (!names.every((n) => typeof n === "string" && n !== "" && !EXCLUDED_META.includes(n)))
|
|
91
|
+
return malformed();
|
|
92
|
+
if (!ascending(names))
|
|
93
|
+
return malformed();
|
|
94
|
+
const { server, name, meta } = request;
|
|
95
|
+
if (!isAbsoluteUri(server))
|
|
96
|
+
return malformed();
|
|
97
|
+
if (params["server"] !== server)
|
|
98
|
+
return refuse("ln/request-server-mismatch");
|
|
99
|
+
if (typeof name !== "string" || name === "")
|
|
100
|
+
return malformed();
|
|
101
|
+
const args = Object.hasOwn(request, "arguments") ? request["arguments"] : {};
|
|
102
|
+
if (!isObject(args))
|
|
103
|
+
return malformed();
|
|
104
|
+
if (meta !== undefined && !isObject(meta))
|
|
105
|
+
return malformed();
|
|
106
|
+
const given = (meta ?? {});
|
|
107
|
+
const bound = [];
|
|
108
|
+
for (const n of names) {
|
|
109
|
+
if (!Object.hasOwn(given, n)) {
|
|
110
|
+
bound.push({ name: n, valueHash: await valueHash(undefined) });
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const text = canonicalJson(given[n]);
|
|
114
|
+
if (typeof text !== "string")
|
|
115
|
+
return malformed();
|
|
116
|
+
bound.push({ name: n, valueHash: await valueHash(new TextEncoder().encode(text)) });
|
|
117
|
+
}
|
|
118
|
+
return { domain: MCP_DOMAIN, server, method: "tools/call", name, arguments: args, metadata: bound };
|
|
119
|
+
}
|
|
120
|
+
/** An absolute URI in ASCII syntax, with no user information and no fragment. */
|
|
121
|
+
function isAbsoluteUri(v) {
|
|
122
|
+
return typeof v === "string" && ASCII_URI.test(v) && ABSOLUTE_URI.test(v) && !USERINFO.test(v) && URL.canParse(v);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The binding object of the buyer's own `request` under a profile and its parameters, the profile being the one the
|
|
126
|
+
* request's transport uses: `http:1` for an HTTP request, `mcp:1` for a `tools/call`.
|
|
127
|
+
*/
|
|
128
|
+
export async function bindingOf(profile, params, request, resourceUrl) {
|
|
129
|
+
if (!isObject(params) || !isObject(request))
|
|
130
|
+
return malformed();
|
|
131
|
+
const isMcp = Object.hasOwn(request, "server");
|
|
132
|
+
if (profile === "http:1" && !isMcp)
|
|
133
|
+
return httpBinding(params, request, resourceUrl);
|
|
134
|
+
if (profile === "mcp:1" && isMcp)
|
|
135
|
+
return mcpBinding(params, request);
|
|
136
|
+
return refuse("ln/request-profile-mismatch");
|
|
137
|
+
}
|
|
138
|
+
/** `requestHash`: lower-case hex of SHA-256 over the UTF-8 of the binding object's RFC 8785 form. */
|
|
139
|
+
export async function requestHashOf(profile, params, request, resourceUrl) {
|
|
140
|
+
const binding = await bindingOf(profile, params, request, resourceUrl);
|
|
141
|
+
if (isRefusal(binding))
|
|
142
|
+
return binding;
|
|
143
|
+
const text = canonicalJson(binding);
|
|
144
|
+
if (typeof text !== "string")
|
|
145
|
+
return malformed();
|
|
146
|
+
return sha256Hex(new TextEncoder().encode(text));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The request hash of the buyer's own `request` under the option's profile, when the option's `extra.requestHash` and
|
|
150
|
+
* the invoice's description hash both equal it; otherwise the refusal naming what differs.
|
|
151
|
+
*/
|
|
152
|
+
export async function checkRequestHash(option, resourceUrl, request) {
|
|
153
|
+
const extra = isObject(option) ? option["extra"] : undefined;
|
|
154
|
+
if (!isObject(extra))
|
|
155
|
+
return malformed();
|
|
156
|
+
const { requestHash, requestBindingProfile: profile, requestBindingParams: params, invoice } = extra;
|
|
157
|
+
if (typeof requestHash !== "string" || !REQUEST_HASH.test(requestHash))
|
|
158
|
+
return malformed();
|
|
159
|
+
const computed = await requestHashOf(profile, params, request, resourceUrl);
|
|
160
|
+
if (isRefusal(computed))
|
|
161
|
+
return computed;
|
|
162
|
+
if (computed !== requestHash)
|
|
163
|
+
return refuse("ln/request-hash-mismatch");
|
|
164
|
+
if (typeof invoice !== "string")
|
|
165
|
+
return refuse("ln/invoice-malformed");
|
|
166
|
+
const b = await decodeBolt11(invoice);
|
|
167
|
+
if (isRefusal(b))
|
|
168
|
+
return b;
|
|
169
|
+
const d = invoiceH(b, "h");
|
|
170
|
+
if (isRefusal(d))
|
|
171
|
+
return d;
|
|
172
|
+
if (d !== `0x${computed}`)
|
|
173
|
+
return refuse("ln/request-hash-mismatch");
|
|
174
|
+
return computed;
|
|
175
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeCard: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeEvmAuthorization: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** The buyer piece for `mpp/charge/evm/authorization`: the token's EIP-712 name and version are the buyer's input. */
|
|
2
|
+
import { mppChargePiece } from "./mpp.js";
|
|
3
|
+
export const mppChargeEvmAuthorization = mppChargePiece("mpp/charge/evm/authorization", { tokenDomain: "object" });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeEvmHash: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeEvmPermit2: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeEvmTransaction: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The buyer piece for `mpp/charge/hedera`: the transaction body whose memo is MPP's attribution memo for the chosen
|
|
3
|
+
* challenge, handed to the payer as `hedera-body`. The node, the valid start, the maximum fee, the optional client id
|
|
4
|
+
* and the optional `credentialType` are the buyer's. A challenge that names no `chainId` is read on the account's own
|
|
5
|
+
* network.
|
|
6
|
+
* - `credentialType` `transaction` (the default, pull): the signer answers `{publicKey, signature, type}`, and the
|
|
7
|
+
* credential is `{challenge, payload: {type: "transaction", transaction}}`, the signed body in base64.
|
|
8
|
+
* - `credentialType` `hash` (push): the build's request carries `broadcast: true`; the signer signs and broadcasts the body and
|
|
9
|
+
* answers `{transactionId}`, which must name the body's payer and valid start. The credential is `{challenge,
|
|
10
|
+
* payload: {type: "hash", transactionId}}`, and `landed` beside it holds the network and the body's memo, which
|
|
11
|
+
* `bound` reads. The signer moves the payment, so a decline keeps it.
|
|
12
|
+
*/
|
|
13
|
+
import type { AtrHash } from "@integraledger/lcp";
|
|
14
|
+
import type { BuyerPiece } from "../types.js";
|
|
15
|
+
/**
|
|
16
|
+
* The binding's build, called with the chosen challenge's id and realm, its decoded request, and the payer's values,
|
|
17
|
+
* `credentialType` among them. The body carries no hash of its own: the challenge's id derives from it, and `bound`
|
|
18
|
+
* reads it from there.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildHederaCharge(choice: unknown, _h: AtrHash): Promise<unknown>;
|
|
21
|
+
export declare const mppChargeHedera: BuyerPiece & {
|
|
22
|
+
build(choice: unknown, h: AtrHash): Promise<unknown>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { attributionMemo, chargeHedera } from "@integraledger/lcp/mpp";
|
|
2
|
+
import { accountOf, bigintOf, broadcasts, bytesOf, choiceOf, inputsOf, isObject, isRefusal, refuse } from "./common.js";
|
|
3
|
+
import { requestOf } from "./mpp.js";
|
|
4
|
+
import { mppRailPiece, railChoose } from "./mpp-rails.js";
|
|
5
|
+
import { HEDERA_ENTITY } from "./x402-exact-hedera.js";
|
|
6
|
+
const PAIRING = "mpp/charge/hedera";
|
|
7
|
+
const KEY_TYPES = ["ed25519", "ecdsa-secp256k1"];
|
|
8
|
+
const CREDENTIAL_TYPES = ["transaction", "hash"];
|
|
9
|
+
/** A Hedera transaction id, `shard.realm.num@seconds.nanos`. */
|
|
10
|
+
const TX_ID = /^((?:0|[1-9][0-9]{0,18})\.(?:0|[1-9][0-9]{0,18})\.(?:0|[1-9][0-9]{0,18}))@(0|[1-9][0-9]{0,18})\.([0-9]{1,9})$/;
|
|
11
|
+
function inputs(_request, given) {
|
|
12
|
+
const read = inputsOf(given, PAIRING, {
|
|
13
|
+
node: "string",
|
|
14
|
+
validStart: "object",
|
|
15
|
+
maxFee: "decimal",
|
|
16
|
+
clientId: "optional-string",
|
|
17
|
+
credentialType: "optional-string",
|
|
18
|
+
});
|
|
19
|
+
if (isRefusal(read))
|
|
20
|
+
return read;
|
|
21
|
+
if (read["credentialType"] !== undefined && !CREDENTIAL_TYPES.includes(read["credentialType"])) {
|
|
22
|
+
return refuse("mpp/input-malformed");
|
|
23
|
+
}
|
|
24
|
+
const validStart = inputsOf(read["validStart"], PAIRING, { seconds: "decimal", nanos: "uint" });
|
|
25
|
+
if (isRefusal(validStart))
|
|
26
|
+
return validStart;
|
|
27
|
+
return { ...read, validStart };
|
|
28
|
+
}
|
|
29
|
+
function revive(c) {
|
|
30
|
+
const vs = c["validStart"];
|
|
31
|
+
const seconds = isObject(vs) ? bigintOf(vs["seconds"]) : undefined;
|
|
32
|
+
const maxFee = bigintOf(c["maxFee"]);
|
|
33
|
+
if (!isObject(vs) || seconds === undefined || maxFee === undefined)
|
|
34
|
+
return refuse("mpp/choice-malformed");
|
|
35
|
+
return { ...c, validStart: { ...vs, seconds }, maxFee };
|
|
36
|
+
}
|
|
37
|
+
/** `{publicKey, signature, type}` with the key and signature as bytes. */
|
|
38
|
+
function answer(signature) {
|
|
39
|
+
if (!isObject(signature))
|
|
40
|
+
return refuse("mpp/credential-malformed");
|
|
41
|
+
const publicKey = bytesOf(signature["publicKey"]);
|
|
42
|
+
const bytes = bytesOf(signature["signature"]);
|
|
43
|
+
const type = signature["type"];
|
|
44
|
+
if (publicKey === undefined || bytes === undefined || typeof type !== "string" || !KEY_TYPES.includes(type)) {
|
|
45
|
+
return refuse("mpp/credential-malformed");
|
|
46
|
+
}
|
|
47
|
+
return { publicKey, signature: bytes, type: type };
|
|
48
|
+
}
|
|
49
|
+
const isPush = (c) => c?.["credentialType"] === "hash";
|
|
50
|
+
/** The push answer's transaction id, when it names the body's payer and valid start. */
|
|
51
|
+
function pushedId(signature, c) {
|
|
52
|
+
const id = isObject(signature) ? signature["transactionId"] : undefined;
|
|
53
|
+
const m = typeof id === "string" ? TX_ID.exec(id) : null;
|
|
54
|
+
if (m === null)
|
|
55
|
+
return refuse("mpp/credential-malformed");
|
|
56
|
+
const vs = c["validStart"];
|
|
57
|
+
const seconds = isObject(vs) ? bigintOf(vs["seconds"]) : undefined;
|
|
58
|
+
const nanos = isObject(vs) ? vs["nanos"] : undefined;
|
|
59
|
+
if (m[1] !== c["payer"] || seconds === undefined || BigInt(m[2]) !== seconds || Number(m[3].padEnd(9, "0")) !== nanos) {
|
|
60
|
+
return refuse("hedera/tx-mismatch");
|
|
61
|
+
}
|
|
62
|
+
return id;
|
|
63
|
+
}
|
|
64
|
+
async function complete(unsigned, signature, chosen) {
|
|
65
|
+
const c = choiceOf(chosen);
|
|
66
|
+
const challenge = c?.["challenge"];
|
|
67
|
+
if (c === undefined || !isObject(challenge))
|
|
68
|
+
return refuse("mpp/choice-malformed");
|
|
69
|
+
const echoed = challenge;
|
|
70
|
+
if (isPush(c)) {
|
|
71
|
+
const transactionId = pushedId(signature, c);
|
|
72
|
+
if (isRefusal(transactionId))
|
|
73
|
+
return transactionId;
|
|
74
|
+
const clientId = typeof c["clientId"] === "string" ? c["clientId"] : undefined;
|
|
75
|
+
const memo = attributionMemo(String(challenge["realm"]), String(challenge["id"]), clientId);
|
|
76
|
+
return { challenge: echoed, payload: { type: "hash", transactionId }, landed: { network: c["network"], memo } };
|
|
77
|
+
}
|
|
78
|
+
const a = answer(signature);
|
|
79
|
+
if (isRefusal(a))
|
|
80
|
+
return a;
|
|
81
|
+
const transaction = unsigned.complete(a);
|
|
82
|
+
if (isRefusal(transaction))
|
|
83
|
+
return transaction;
|
|
84
|
+
return { challenge: echoed, payload: { type: "transaction", transaction } };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The binding's build, called with the chosen challenge's id and realm, its decoded request, and the payer's values,
|
|
88
|
+
* `credentialType` among them. The body carries no hash of its own: the challenge's id derives from it, and `bound`
|
|
89
|
+
* reads it from there.
|
|
90
|
+
*/
|
|
91
|
+
export async function buildHederaCharge(choice, _h) {
|
|
92
|
+
if (isRefusal(choice))
|
|
93
|
+
return choice;
|
|
94
|
+
const c = choice;
|
|
95
|
+
const request = requestOf(c.challenge);
|
|
96
|
+
if (request === undefined || typeof c.challenge.id !== "string")
|
|
97
|
+
return refuse("mpp/choice-malformed");
|
|
98
|
+
return chargeHedera.build({ id: c.challenge.id, realm: c.challenge.realm }, request, {
|
|
99
|
+
payer: c.payer,
|
|
100
|
+
node: c.node,
|
|
101
|
+
validStart: c.validStart,
|
|
102
|
+
maxFee: c.maxFee,
|
|
103
|
+
...(c.clientId !== undefined ? { clientId: c.clientId } : {}),
|
|
104
|
+
...(c.credentialType !== undefined ? { credentialType: c.credentialType } : {}),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const spec = {
|
|
108
|
+
pairing: PAIRING,
|
|
109
|
+
namespace: "hedera",
|
|
110
|
+
address: HEDERA_ENTITY,
|
|
111
|
+
payer: "payer",
|
|
112
|
+
now: false,
|
|
113
|
+
inputs,
|
|
114
|
+
revive,
|
|
115
|
+
complete,
|
|
116
|
+
network: (c, accountNetwork) => chargeHedera.network(requestOf(c), accountNetwork),
|
|
117
|
+
};
|
|
118
|
+
const rail = mppRailPiece(spec);
|
|
119
|
+
const railChosen = railChoose(spec);
|
|
120
|
+
/** The choice, with the account's network, which the challenge's network equals, for a push credential's `landed`. */
|
|
121
|
+
function choose(...args) {
|
|
122
|
+
const chosen = railChosen(...args);
|
|
123
|
+
if (isRefusal(chosen))
|
|
124
|
+
return chosen;
|
|
125
|
+
const network = accountOf(args[1]).network;
|
|
126
|
+
return { ...chosen, choice: { ...chosen.choice, network } };
|
|
127
|
+
}
|
|
128
|
+
export const mppChargeHedera = Object.freeze({
|
|
129
|
+
...rail,
|
|
130
|
+
choose,
|
|
131
|
+
build: buildHederaCharge,
|
|
132
|
+
moves: broadcasts,
|
|
133
|
+
sent(signed) {
|
|
134
|
+
const { landed: _landed, ...credential } = signed;
|
|
135
|
+
return credential;
|
|
136
|
+
},
|
|
137
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { refuse } from "./common.js";
|
|
2
|
+
import { railChoose } from "./mpp-rails.js";
|
|
3
|
+
const PAIRING = "mpp/charge/nearintents";
|
|
4
|
+
const nothingToSign = () => refuse("mpp/nothing-to-sign");
|
|
5
|
+
export const mppChargeNearIntents = Object.freeze({
|
|
6
|
+
choose: railChoose({
|
|
7
|
+
pairing: PAIRING,
|
|
8
|
+
namespace: null,
|
|
9
|
+
address: /^.+$/,
|
|
10
|
+
payer: null,
|
|
11
|
+
now: false,
|
|
12
|
+
inputs: () => ({}),
|
|
13
|
+
revive: (c) => c,
|
|
14
|
+
complete: async () => nothingToSign(),
|
|
15
|
+
}),
|
|
16
|
+
choice: (_chosen) => nothingToSign(),
|
|
17
|
+
request: () => nothingToSign(),
|
|
18
|
+
complete: async () => nothingToSign(),
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeSolana: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { inputsOf, isObject } from "./common.js";
|
|
2
|
+
import { completeWith, mppRailPiece, signature64 } from "./mpp-rails.js";
|
|
3
|
+
import { SOLANA_ADDRESS, withUnitPrice } from "./x402-exact-solana.js";
|
|
4
|
+
const PAIRING = "mpp/charge/solana";
|
|
5
|
+
function inputs(request, given) {
|
|
6
|
+
const d = isObject(request["methodDetails"]) ? request["methodDetails"] : {};
|
|
7
|
+
const native = request["currency"] === "sol";
|
|
8
|
+
return inputsOf(given, PAIRING, {
|
|
9
|
+
...(native || typeof d["decimals"] === "number" ? {} : { decimals: "uint" }),
|
|
10
|
+
...(native || typeof d["tokenProgram"] === "string" ? {} : { tokenProgram: "string" }),
|
|
11
|
+
...(typeof d["recentBlockhash"] === "string" ? {} : { recentBlockhash: "string" }),
|
|
12
|
+
computeUnitLimit: "optional-uint",
|
|
13
|
+
computeUnitPrice: "optional-decimal",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export const mppChargeSolana = mppRailPiece({
|
|
17
|
+
pairing: PAIRING,
|
|
18
|
+
namespace: "solana",
|
|
19
|
+
address: SOLANA_ADDRESS,
|
|
20
|
+
payer: "payer",
|
|
21
|
+
now: false,
|
|
22
|
+
inputs,
|
|
23
|
+
revive: withUnitPrice,
|
|
24
|
+
complete: completeWith(signature64),
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeStellar: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { inputsOf } from "./common.js";
|
|
2
|
+
import { completeWith, mppRailPiece, signature64, STELLAR_ACCOUNT } from "./mpp-rails.js";
|
|
3
|
+
const PAIRING = "mpp/charge/stellar";
|
|
4
|
+
function inputs(_request, given) {
|
|
5
|
+
return inputsOf(given, PAIRING, { simulatedXdr: "string", currentLedger: "uint" });
|
|
6
|
+
}
|
|
7
|
+
export const mppChargeStellar = mppRailPiece({
|
|
8
|
+
pairing: PAIRING,
|
|
9
|
+
namespace: "stellar",
|
|
10
|
+
address: STELLAR_ACCOUNT,
|
|
11
|
+
payer: null,
|
|
12
|
+
now: true,
|
|
13
|
+
inputs,
|
|
14
|
+
revive: (c) => c,
|
|
15
|
+
complete: completeWith(signature64),
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeStripe: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const mppChargeTempoMemo: Readonly<{
|
|
2
|
+
choose(read: import("../types.js").Read, account: string, inputs: import("../types.js").Inputs, now: number, ref: string, doc: unknown): ReturnType<import("../types.js").Choose> | Promise<ReturnType<import("../types.js").Choose>>;
|
|
3
|
+
choice(chosen: import("../types.js").Chosen, bytes: Uint8Array): unknown;
|
|
4
|
+
request(unsigned: unknown): import("../types.js").SigningRequest | null | import("@integraledger/lcp").Refusal;
|
|
5
|
+
complete(unsigned: unknown, signature: import("../types.js").Signature, chosen: import("../types.js").Chosen): Promise<import("../types.js").Presented | import("../types.js").Next | import("@integraledger/lcp").Refusal>;
|
|
6
|
+
sent?(signed: import("../types.js").Presented): import("../types.js").Presented;
|
|
7
|
+
moves?(request: import("../types.js").SigningRequest): boolean;
|
|
8
|
+
build: (choice: unknown, h: import("@integraledger/lcp").AtrHash) => Promise<unknown>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The buyer piece for `mpp/charge/tempo/memo`: the answer is the signed `0x76` transaction; `clientId` is optional.
|
|
3
|
+
* With splits, the transaction carries one call per recipient.
|
|
4
|
+
*/
|
|
5
|
+
import { tempoMemo } from "@integraledger/lcp/mpp";
|
|
6
|
+
import { acceptSplits, mppChargePiece, tempoBuild } from "./mpp.js";
|
|
7
|
+
export const mppChargeTempoMemo = Object.freeze({
|
|
8
|
+
...mppChargePiece("mpp/charge/tempo/memo", { clientId: "optional-string" }, acceptSplits),
|
|
9
|
+
build: tempoBuild(tempoMemo),
|
|
10
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Presented } from "../types.js";
|
|
2
|
+
import { broadcasts } from "./common.js";
|
|
3
|
+
import { mppChoice, mppRequest, pushComplete } from "./mpp.js";
|
|
4
|
+
export declare const mppChargeTempoPush: Readonly<{
|
|
5
|
+
choose: import("../types.js").Choose;
|
|
6
|
+
choice: typeof mppChoice;
|
|
7
|
+
build: (choice: unknown, h: import("../types.js").AtrHash) => Promise<unknown>;
|
|
8
|
+
request: typeof mppRequest;
|
|
9
|
+
complete: typeof pushComplete;
|
|
10
|
+
moves: typeof broadcasts;
|
|
11
|
+
sent(signed: Presented): Presented;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The buyer piece for `mpp/charge/tempo/push`: the signer broadcasts and answers the hash with its landed receipt, which
|
|
3
|
+
* `bound` reads for the memo. The payment sent is the credential without the landed receipt. The signer moves the
|
|
4
|
+
* payment, so a decline keeps it. With splits, the
|
|
5
|
+
* transaction carries one call per recipient.
|
|
6
|
+
*/
|
|
7
|
+
import { tempoPush } from "@integraledger/lcp/mpp";
|
|
8
|
+
import { broadcasts } from "./common.js";
|
|
9
|
+
import { acceptSplits, mppChoice, mppChoose, mppRequest, pushComplete, tempoBuild } from "./mpp.js";
|
|
10
|
+
export const mppChargeTempoPush = Object.freeze({
|
|
11
|
+
choose: mppChoose("mpp/charge/tempo/push", { clientId: "optional-string" }, acceptSplits),
|
|
12
|
+
choice: mppChoice,
|
|
13
|
+
build: tempoBuild(tempoPush),
|
|
14
|
+
request: mppRequest,
|
|
15
|
+
complete: pushComplete,
|
|
16
|
+
moves: broadcasts,
|
|
17
|
+
sent(signed) {
|
|
18
|
+
const { landed: _landed, ...credential } = signed;
|
|
19
|
+
return credential;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeUsdcEvm: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The buyer piece for `mpp/charge/usdc/evm`: the EIP-3009 authorization whose nonce is usdc's derivation over the
|
|
3
|
+
* challenge; the token's EIP-712 name and version are the buyer's input.
|
|
4
|
+
*/
|
|
5
|
+
import { mppChargePiece } from "./mpp.js";
|
|
6
|
+
export const mppChargeUsdcEvm = mppChargePiece("mpp/charge/usdc/evm", { tokenDomain: "object" });
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { accountOf, isObject, refuse } from "./common.js";
|
|
2
|
+
import { offers, requestOf } from "./mpp.js";
|
|
3
|
+
import { builtRequest, completeWith } from "./mpp-rails.js";
|
|
4
|
+
const PAIRING = "mpp/charge/usdc/gateway";
|
|
5
|
+
/** The Gateway source networks a challenge accepts. */
|
|
6
|
+
function acceptedSources(c) {
|
|
7
|
+
const md = requestOf(c)?.["methodDetails"];
|
|
8
|
+
const g = isObject(md) ? md["gateway"] : undefined;
|
|
9
|
+
const sources = isObject(g) ? g["acceptedSources"] : undefined;
|
|
10
|
+
return Array.isArray(sources) ? sources : [];
|
|
11
|
+
}
|
|
12
|
+
function answerOf(signature) {
|
|
13
|
+
return isObject(signature) ? signature : refuse("mpp/credential-malformed");
|
|
14
|
+
}
|
|
15
|
+
export const mppChargeUsdcGateway = Object.freeze({
|
|
16
|
+
choose(read, account, _inputs, now, ref) {
|
|
17
|
+
const a = accountOf(account);
|
|
18
|
+
if (a === undefined)
|
|
19
|
+
return refuse("mpp/no-payable-option");
|
|
20
|
+
const offer = read.offer;
|
|
21
|
+
const challenges = isObject(offer) && Array.isArray(offer["challenges"]) ? offer["challenges"] : [];
|
|
22
|
+
const challenge = challenges.find((c) => offers(c, PAIRING) && acceptedSources(c).includes(a.network));
|
|
23
|
+
if (challenge === undefined)
|
|
24
|
+
return refuse("mpp/no-payable-option");
|
|
25
|
+
return { pairing: PAIRING, choice: { challenge: challenge, from: a.address, now }, ref };
|
|
26
|
+
},
|
|
27
|
+
choice(chosen) {
|
|
28
|
+
const c = isObject(chosen) && isObject(chosen.choice) ? chosen.choice : undefined;
|
|
29
|
+
return c === undefined || !isObject(c["challenge"]) ? refuse("mpp/choice-malformed") : c;
|
|
30
|
+
},
|
|
31
|
+
request: builtRequest,
|
|
32
|
+
complete: completeWith(answerOf),
|
|
33
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeUsdcSolana: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { inputsOf, isObject } from "./common.js";
|
|
2
|
+
import { completeWith, mppRailPiece, signature64 } from "./mpp-rails.js";
|
|
3
|
+
import { SOLANA_ADDRESS, withUnitPrice } from "./x402-exact-solana.js";
|
|
4
|
+
const PAIRING = "mpp/charge/usdc/solana";
|
|
5
|
+
function inputs(request, given) {
|
|
6
|
+
const md = isObject(request["methodDetails"]) ? request["methodDetails"] : {};
|
|
7
|
+
const d = isObject(md["solana"]) ? md["solana"] : {};
|
|
8
|
+
return inputsOf(given, PAIRING, {
|
|
9
|
+
...(typeof d["decimals"] === "number" ? {} : { decimals: "uint" }),
|
|
10
|
+
...(typeof d["tokenProgram"] === "string" ? {} : { tokenProgram: "string" }),
|
|
11
|
+
...(typeof d["recentBlockhash"] === "string" ? {} : { recentBlockhash: "string" }),
|
|
12
|
+
computeUnitLimit: "optional-uint",
|
|
13
|
+
computeUnitPrice: "optional-decimal",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export const mppChargeUsdcSolana = mppRailPiece({
|
|
17
|
+
pairing: PAIRING,
|
|
18
|
+
namespace: "solana",
|
|
19
|
+
address: SOLANA_ADDRESS,
|
|
20
|
+
payer: "payer",
|
|
21
|
+
now: false,
|
|
22
|
+
inputs,
|
|
23
|
+
revive: withUnitPrice,
|
|
24
|
+
complete: completeWith(signature64),
|
|
25
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeUsdcStacks: import("../types.js").BuyerPiece;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { bytesOf, refuse } from "./common.js";
|
|
2
|
+
import { completeWith, mppRailPiece } from "./mpp-rails.js";
|
|
3
|
+
const PAIRING = "mpp/charge/usdc/stacks";
|
|
4
|
+
const C32_PRINCIPAL = /^S[0-9A-HJKMNP-TV-Z]{38,40}$/;
|
|
5
|
+
function transactionBytes(signature) {
|
|
6
|
+
return bytesOf(signature) ?? refuse("mpp/credential-malformed");
|
|
7
|
+
}
|
|
8
|
+
export const mppChargeUsdcStacks = mppRailPiece({
|
|
9
|
+
pairing: PAIRING,
|
|
10
|
+
namespace: "stacks",
|
|
11
|
+
address: C32_PRINCIPAL,
|
|
12
|
+
payer: "from",
|
|
13
|
+
now: false,
|
|
14
|
+
inputs: () => ({}),
|
|
15
|
+
revive: (c) => c,
|
|
16
|
+
complete: completeWith(transactionBytes),
|
|
17
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mppChargeXrpl: import("../types.js").BuyerPiece;
|