@agenticprimitives/payments 0.0.0-alpha.41 → 0.0.0-alpha.43
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/entitlement/index.d.ts.map +1 -1
- package/dist/entitlement/index.js +10 -4
- package/dist/entitlement/index.js.map +1 -1
- package/dist/entitlement/voucher.d.ts +14 -1
- package/dist/entitlement/voucher.d.ts.map +1 -1
- package/dist/entitlement/voucher.js +20 -1
- package/dist/entitlement/voucher.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mandate-sign.d.ts +42 -3
- package/dist/mandate-sign.d.ts.map +1 -1
- package/dist/mandate-sign.js +33 -2
- package/dist/mandate-sign.js.map +1 -1
- package/dist/mandate.d.ts +10 -2
- package/dist/mandate.d.ts.map +1 -1
- package/dist/mandate.js +9 -2
- package/dist/mandate.js.map +1 -1
- package/dist/ops.d.ts +45 -4
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js +59 -10
- package/dist/ops.js.map +1 -1
- package/dist/rails/escrow.d.ts +11 -3
- package/dist/rails/escrow.d.ts.map +1 -1
- package/dist/rails/escrow.js +11 -2
- package/dist/rails/escrow.js.map +1 -1
- package/dist/rails/invoice.d.ts +6 -4
- package/dist/rails/invoice.d.ts.map +1 -1
- package/dist/rails/invoice.js +6 -5
- package/dist/rails/invoice.js.map +1 -1
- package/dist/rails/recurring.d.ts +7 -3
- package/dist/rails/recurring.d.ts.map +1 -1
- package/dist/rails/recurring.js +8 -5
- package/dist/rails/recurring.js.map +1 -1
- package/dist/rails/wallet.d.ts +8 -6
- package/dist/rails/wallet.d.ts.map +1 -1
- package/dist/rails/wallet.js +12 -9
- package/dist/rails/wallet.js.map +1 -1
- package/dist/rails/x402/executor.d.ts +124 -9
- package/dist/rails/x402/executor.d.ts.map +1 -1
- package/dist/rails/x402/executor.js +107 -13
- package/dist/rails/x402/executor.js.map +1 -1
- package/dist/rails/x402/index.d.ts +2 -2
- package/dist/rails/x402/index.d.ts.map +1 -1
- package/dist/rails/x402/index.js +1 -1
- package/dist/rails/x402/index.js.map +1 -1
- package/dist/rails/x402/wire.d.ts.map +1 -1
- package/dist/rails/x402/wire.js +18 -1
- package/dist/rails/x402/wire.js.map +1 -1
- package/dist/refund.d.ts +9 -2
- package/dist/refund.d.ts.map +1 -1
- package/dist/refund.js +10 -3
- package/dist/refund.js.map +1 -1
- package/dist/split.d.ts +7 -2
- package/dist/split.d.ts.map +1 -1
- package/dist/split.js +8 -3
- package/dist/split.js.map +1 -1
- package/dist/transfer.d.ts +24 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transfer.js +21 -5
- package/dist/transfer.js.map +1 -1
- package/dist/treasury.d.ts +50 -0
- package/dist/treasury.d.ts.map +1 -0
- package/dist/treasury.js +68 -0
- package/dist/treasury.js.map +1 -0
- package/package.json +5 -5
package/dist/split.d.ts
CHANGED
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
* pattern). `bps` MUST sum to 10000; the rounding remainder is assigned to the first recipient
|
|
6
6
|
* so the legs total EXACTLY `amount` (no dust left in the treasury). Each leg is its own
|
|
7
7
|
* transfer plan (and its own receipt). Connected-account onboarding / KYB stays app layer.
|
|
8
|
+
*
|
|
9
|
+
* Spec 445 / ontology ONT-4: the paying treasury (`payer`) and every recipient must be treasuries; a person or
|
|
10
|
+
* organization recipient is refused (`isTreasury`, REQUIRED).
|
|
8
11
|
*/
|
|
9
12
|
import type { Address } from '@agenticprimitives/types';
|
|
10
13
|
import { type TransferPlan } from './transfer.js';
|
|
14
|
+
import { type TreasuryPort } from './treasury.js';
|
|
11
15
|
export interface SplitRecipient {
|
|
12
16
|
to: Address;
|
|
13
17
|
bps: number;
|
|
@@ -22,6 +26,7 @@ export declare const BPS_DENOMINATOR = 10000;
|
|
|
22
26
|
export declare function buildSplitPayout(input: {
|
|
23
27
|
asset: Address;
|
|
24
28
|
amount: bigint;
|
|
25
|
-
recipients: SplitRecipient[];
|
|
26
|
-
|
|
29
|
+
recipients: SplitRecipient[]; /** the paying treasury that executes every leg */
|
|
30
|
+
payer: Address;
|
|
31
|
+
}, deps: TreasuryPort): Promise<SplitLeg[]>;
|
|
27
32
|
//# sourceMappingURL=split.d.ts.map
|
package/dist/split.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../src/split.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../src/split.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAEzE,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,OAAO,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC,wBAAsB,gBAAgB,CACpC,KAAK,EAAE;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC,kDAAkD;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAC1I,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAmBrB"}
|
package/dist/split.js
CHANGED
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
* pattern). `bps` MUST sum to 10000; the rounding remainder is assigned to the first recipient
|
|
6
6
|
* so the legs total EXACTLY `amount` (no dust left in the treasury). Each leg is its own
|
|
7
7
|
* transfer plan (and its own receipt). Connected-account onboarding / KYB stays app layer.
|
|
8
|
+
*
|
|
9
|
+
* Spec 445 / ontology ONT-4: the paying treasury (`payer`) and every recipient must be treasuries; a person or
|
|
10
|
+
* organization recipient is refused (`isTreasury`, REQUIRED).
|
|
8
11
|
*/
|
|
9
|
-
import {
|
|
12
|
+
import { encodeErc20Transfer } from './transfer.js';
|
|
13
|
+
import { assertTreasuryParties } from './treasury.js';
|
|
10
14
|
export const BPS_DENOMINATOR = 10_000;
|
|
11
|
-
export function buildSplitPayout(input) {
|
|
15
|
+
export async function buildSplitPayout(input, deps) {
|
|
12
16
|
const { asset, amount, recipients } = input;
|
|
13
17
|
if (recipients.length === 0)
|
|
14
18
|
throw new Error('[split] at least one recipient required');
|
|
@@ -20,6 +24,7 @@ export function buildSplitPayout(input) {
|
|
|
20
24
|
for (const r of recipients)
|
|
21
25
|
if (r.bps <= 0)
|
|
22
26
|
throw new Error('[split] each recipient bps must be > 0');
|
|
27
|
+
await assertTreasuryParties(deps, { payers: [input.payer], payees: recipients.map((r) => r.to) });
|
|
23
28
|
const amounts = recipients.map((r) => (amount * BigInt(r.bps)) / BigInt(BPS_DENOMINATOR));
|
|
24
29
|
const remainder = amount - amounts.reduce((s, a) => s + a, 0n);
|
|
25
30
|
amounts[0] += remainder; // assign rounding dust to the first recipient → legs total exactly `amount`
|
|
@@ -27,7 +32,7 @@ export function buildSplitPayout(input) {
|
|
|
27
32
|
to: r.to,
|
|
28
33
|
bps: r.bps,
|
|
29
34
|
amount: amounts[i],
|
|
30
|
-
plan:
|
|
35
|
+
plan: encodeErc20Transfer(asset, r.to, amounts[i]),
|
|
31
36
|
}));
|
|
32
37
|
}
|
|
33
38
|
//# sourceMappingURL=split.js.map
|
package/dist/split.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split.js","sourceRoot":"","sources":["../src/split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EAAE,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;IAC1F,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/D,OAAO,CAAC,CAAC,CAAE,IAAI,SAAS,CAAC,CAAC,4EAA4E;IAEtG,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/B,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,MAAM,EAAE,OAAO,CAAC,CAAC,CAAE;QACnB,IAAI,EAAE,mBAAmB,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,CAAE,CAAC;KACpD,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/dist/transfer.d.ts
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
* A `TransferPlan` is the inner call an SA executes (`AgentAccount.execute(to, value, data)`
|
|
5
5
|
* or a UserOp / wallet tx) — the same `{to, value, data}` shape the x402 rail's
|
|
6
6
|
* `buildRedemptionCalldata` returns. Wallet / invoice / refund / split all reduce to one or
|
|
7
|
-
* more ERC-20 transfers from the
|
|
7
|
+
* more ERC-20 transfers from the paying TREASURY SA into the receiving TREASURY SA.
|
|
8
|
+
*
|
|
9
|
+
* Spec 445 / ontology ONT-4: assets live only in treasuries (`appr:ValueHolder ≡ ap:Treasury`). The exported
|
|
10
|
+
* planners take the payer and payee and the REQUIRED `isTreasury` port, and refuse a person or organization
|
|
11
|
+
* address on either side. The bare encoders below (`encodeErc20Transfer`, `encodeNativeTransfer`) are
|
|
12
|
+
* package-internal: every caller has already checked both parties.
|
|
8
13
|
*/
|
|
9
14
|
import { type Address, type Hex } from 'viem';
|
|
15
|
+
import { type TreasuryPort } from './treasury.js';
|
|
10
16
|
export interface TransferPlan {
|
|
11
17
|
to: Address;
|
|
12
18
|
value: bigint;
|
|
@@ -27,10 +33,23 @@ export declare const ERC20_TRANSFER_ABI: readonly [{
|
|
|
27
33
|
readonly type: "bool";
|
|
28
34
|
}];
|
|
29
35
|
}];
|
|
30
|
-
/**
|
|
31
|
-
export declare function
|
|
32
|
-
/**
|
|
33
|
-
export declare function
|
|
36
|
+
/** Package-internal: encode `asset.transfer(to, amount)`. Parties MUST already be checked. Not exported from the root. */
|
|
37
|
+
export declare function encodeErc20Transfer(asset: Address, to: Address, amount: bigint): TransferPlan;
|
|
38
|
+
/** Package-internal: encode a native-value send. Parties MUST already be checked. Not exported from the root. */
|
|
39
|
+
export declare function encodeNativeTransfer(to: Address, amount: bigint): TransferPlan;
|
|
40
|
+
export interface TreasuryTransferInput {
|
|
41
|
+
/** the paying treasury — the SA that executes the plan */
|
|
42
|
+
payer: Address;
|
|
43
|
+
/** the receiving treasury */
|
|
44
|
+
payee: Address;
|
|
45
|
+
amount: bigint;
|
|
46
|
+
}
|
|
47
|
+
/** A single ERC-20 transfer treasury → treasury: the paying treasury calls `asset.transfer(payee, amount)`. */
|
|
48
|
+
export declare function buildErc20Transfer(input: TreasuryTransferInput & {
|
|
49
|
+
asset: Address;
|
|
50
|
+
}, deps: TreasuryPort): Promise<TransferPlan>;
|
|
51
|
+
/** A native-value transfer treasury → treasury (the paying treasury sends `amount` wei to the payee). */
|
|
52
|
+
export declare function buildNativeTransfer(input: TreasuryTransferInput, deps: TreasuryPort): Promise<TransferPlan>;
|
|
34
53
|
export declare const ERC20_APPROVE_ABI: readonly [{
|
|
35
54
|
readonly type: "function";
|
|
36
55
|
readonly name: "approve";
|
package/dist/transfer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":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AAO,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAMhG"}
|
package/dist/transfer.js
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
* A `TransferPlan` is the inner call an SA executes (`AgentAccount.execute(to, value, data)`
|
|
5
5
|
* or a UserOp / wallet tx) — the same `{to, value, data}` shape the x402 rail's
|
|
6
6
|
* `buildRedemptionCalldata` returns. Wallet / invoice / refund / split all reduce to one or
|
|
7
|
-
* more ERC-20 transfers from the
|
|
7
|
+
* more ERC-20 transfers from the paying TREASURY SA into the receiving TREASURY SA.
|
|
8
|
+
*
|
|
9
|
+
* Spec 445 / ontology ONT-4: assets live only in treasuries (`appr:ValueHolder ≡ ap:Treasury`). The exported
|
|
10
|
+
* planners take the payer and payee and the REQUIRED `isTreasury` port, and refuse a person or organization
|
|
11
|
+
* address on either side. The bare encoders below (`encodeErc20Transfer`, `encodeNativeTransfer`) are
|
|
12
|
+
* package-internal: every caller has already checked both parties.
|
|
8
13
|
*/
|
|
9
14
|
import { encodeFunctionData } from 'viem';
|
|
15
|
+
import { assertTreasuryParties } from './treasury.js';
|
|
10
16
|
export const ERC20_TRANSFER_ABI = [
|
|
11
17
|
{
|
|
12
18
|
type: 'function',
|
|
@@ -19,18 +25,28 @@ export const ERC20_TRANSFER_ABI = [
|
|
|
19
25
|
outputs: [{ type: 'bool' }],
|
|
20
26
|
},
|
|
21
27
|
];
|
|
22
|
-
/**
|
|
23
|
-
export function
|
|
28
|
+
/** Package-internal: encode `asset.transfer(to, amount)`. Parties MUST already be checked. Not exported from the root. */
|
|
29
|
+
export function encodeErc20Transfer(asset, to, amount) {
|
|
24
30
|
return {
|
|
25
31
|
to: asset,
|
|
26
32
|
value: 0n,
|
|
27
33
|
data: encodeFunctionData({ abi: ERC20_TRANSFER_ABI, functionName: 'transfer', args: [to, amount] }),
|
|
28
34
|
};
|
|
29
35
|
}
|
|
30
|
-
/**
|
|
31
|
-
export function
|
|
36
|
+
/** Package-internal: encode a native-value send. Parties MUST already be checked. Not exported from the root. */
|
|
37
|
+
export function encodeNativeTransfer(to, amount) {
|
|
32
38
|
return { to, value: amount, data: '0x' };
|
|
33
39
|
}
|
|
40
|
+
/** A single ERC-20 transfer treasury → treasury: the paying treasury calls `asset.transfer(payee, amount)`. */
|
|
41
|
+
export async function buildErc20Transfer(input, deps) {
|
|
42
|
+
await assertTreasuryParties(deps, { payers: [input.payer], payees: [input.payee] });
|
|
43
|
+
return encodeErc20Transfer(input.asset, input.payee, input.amount);
|
|
44
|
+
}
|
|
45
|
+
/** A native-value transfer treasury → treasury (the paying treasury sends `amount` wei to the payee). */
|
|
46
|
+
export async function buildNativeTransfer(input, deps) {
|
|
47
|
+
await assertTreasuryParties(deps, { payers: [input.payer], payees: [input.payee] });
|
|
48
|
+
return encodeNativeTransfer(input.payee, input.amount);
|
|
49
|
+
}
|
|
34
50
|
export const ERC20_APPROVE_ABI = [
|
|
35
51
|
{
|
|
36
52
|
type: 'function',
|
package/dist/transfer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,kBAAkB,EAA0B,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAqB,MAAM,eAAe,CAAC;AAQzE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;YAC/B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,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UAAU;QAChB,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACpC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;KAC5B;CACO,CAAC;AAEX,8FAA8F;AAC9F,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,OAAgB,EAAE,MAAc;IAChF,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,kBAAkB,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;KACvG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value moves treasury → treasury (spec 420 / spec 445, ontology ONT-4).
|
|
3
|
+
*
|
|
4
|
+
* Assets live ONLY in treasuries: `appr:ValueHolder ≡ ap:Treasury`, and `appay:payer` / `appay:payee` /
|
|
5
|
+
* `ap:primaryPayer` / `ap:primaryPayee` range over `ap:Treasury`. A balance on a person or organization agent
|
|
6
|
+
* is ignored and is never paid from or into. Every payments entry point that accepts a payer or payee for a
|
|
7
|
+
* value move asks this port about each party and refuses a non-treasury with a distinct reason.
|
|
8
|
+
*
|
|
9
|
+
* The package does NOT read the chain: `isTreasury` is INJECTED. The app answers it from the agent's on-chain
|
|
10
|
+
* type record (`atl:agentType` = `treasury` on the SA subject, AgentProfileResolver) — never from a name suffix,
|
|
11
|
+
* a profile string or a guess. The port is REQUIRED; a missing port refuses (fail closed, ADR-0013), and a port
|
|
12
|
+
* that throws refuses the move rather than proceeding.
|
|
13
|
+
*/
|
|
14
|
+
import type { Address } from '@agenticprimitives/types';
|
|
15
|
+
/** Is this address a treasury agent? Answered by the app from the on-chain type record. */
|
|
16
|
+
export type IsTreasury = (address: Address) => Promise<boolean>;
|
|
17
|
+
/** The deps every value-move entry point takes. `isTreasury` is REQUIRED. */
|
|
18
|
+
export interface TreasuryPort {
|
|
19
|
+
isTreasury: IsTreasury;
|
|
20
|
+
}
|
|
21
|
+
export type TreasuryRefusalCode = 'PAYER_NOT_TREASURY' | 'PAYEE_NOT_TREASURY' | 'TREASURY_PORT_MISSING';
|
|
22
|
+
export declare const TREASURY_REFUSAL_REASON: Record<TreasuryRefusalCode, string>;
|
|
23
|
+
export type TreasuryCheck = {
|
|
24
|
+
ok: true;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
code: TreasuryRefusalCode;
|
|
28
|
+
reason: string;
|
|
29
|
+
address?: Address;
|
|
30
|
+
};
|
|
31
|
+
/** Thrown by the synchronous-shaped builders when a party is not a treasury. `code` is the distinct reason. */
|
|
32
|
+
export declare class NotATreasuryError extends Error {
|
|
33
|
+
readonly code: TreasuryRefusalCode;
|
|
34
|
+
readonly address?: Address;
|
|
35
|
+
constructor(code: TreasuryRefusalCode, address?: Address);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Ask the port about every named party. Payers are checked first, then payees; the first refusal wins.
|
|
39
|
+
* A port that is absent or throws is a refusal, never a pass.
|
|
40
|
+
*/
|
|
41
|
+
export declare function checkTreasuryParties(deps: Partial<TreasuryPort> | undefined, parties: {
|
|
42
|
+
payers?: readonly Address[];
|
|
43
|
+
payees?: readonly Address[];
|
|
44
|
+
}): Promise<TreasuryCheck>;
|
|
45
|
+
/** `checkTreasuryParties`, throwing `NotATreasuryError` on refusal. */
|
|
46
|
+
export declare function assertTreasuryParties(deps: Partial<TreasuryPort> | undefined, parties: {
|
|
47
|
+
payers?: readonly Address[];
|
|
48
|
+
payees?: readonly Address[];
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
//# sourceMappingURL=treasury.d.ts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CACzC,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,EACvC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,GACpE,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
package/dist/treasury.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value moves treasury → treasury (spec 420 / spec 445, ontology ONT-4).
|
|
3
|
+
*
|
|
4
|
+
* Assets live ONLY in treasuries: `appr:ValueHolder ≡ ap:Treasury`, and `appay:payer` / `appay:payee` /
|
|
5
|
+
* `ap:primaryPayer` / `ap:primaryPayee` range over `ap:Treasury`. A balance on a person or organization agent
|
|
6
|
+
* is ignored and is never paid from or into. Every payments entry point that accepts a payer or payee for a
|
|
7
|
+
* value move asks this port about each party and refuses a non-treasury with a distinct reason.
|
|
8
|
+
*
|
|
9
|
+
* The package does NOT read the chain: `isTreasury` is INJECTED. The app answers it from the agent's on-chain
|
|
10
|
+
* type record (`atl:agentType` = `treasury` on the SA subject, AgentProfileResolver) — never from a name suffix,
|
|
11
|
+
* a profile string or a guess. The port is REQUIRED; a missing port refuses (fail closed, ADR-0013), and a port
|
|
12
|
+
* that throws refuses the move rather than proceeding.
|
|
13
|
+
*/
|
|
14
|
+
export const TREASURY_REFUSAL_REASON = {
|
|
15
|
+
PAYER_NOT_TREASURY: 'payer is not a treasury — value moves only from a treasury (ap:Treasury)',
|
|
16
|
+
PAYEE_NOT_TREASURY: 'payee is not a treasury — value moves only into a treasury (ap:Treasury)',
|
|
17
|
+
TREASURY_PORT_MISSING: 'no isTreasury port — a value move cannot be checked, so it is refused',
|
|
18
|
+
};
|
|
19
|
+
/** Thrown by the synchronous-shaped builders when a party is not a treasury. `code` is the distinct reason. */
|
|
20
|
+
export class NotATreasuryError extends Error {
|
|
21
|
+
code;
|
|
22
|
+
address;
|
|
23
|
+
constructor(code, address) {
|
|
24
|
+
super(`[payments/treasury] ${TREASURY_REFUSAL_REASON[code]}${address ? ` (${address})` : ''}`);
|
|
25
|
+
this.name = 'NotATreasuryError';
|
|
26
|
+
this.code = code;
|
|
27
|
+
this.address = address;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const refuse = (code, address) => ({
|
|
31
|
+
ok: false,
|
|
32
|
+
code,
|
|
33
|
+
reason: TREASURY_REFUSAL_REASON[code],
|
|
34
|
+
...(address ? { address } : {}),
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Ask the port about every named party. Payers are checked first, then payees; the first refusal wins.
|
|
38
|
+
* A port that is absent or throws is a refusal, never a pass.
|
|
39
|
+
*/
|
|
40
|
+
export async function checkTreasuryParties(deps, parties) {
|
|
41
|
+
const isTreasury = deps?.isTreasury;
|
|
42
|
+
if (typeof isTreasury !== 'function')
|
|
43
|
+
return refuse('TREASURY_PORT_MISSING');
|
|
44
|
+
for (const [list, code] of [
|
|
45
|
+
[parties.payers ?? [], 'PAYER_NOT_TREASURY'],
|
|
46
|
+
[parties.payees ?? [], 'PAYEE_NOT_TREASURY'],
|
|
47
|
+
]) {
|
|
48
|
+
for (const address of list) {
|
|
49
|
+
let yes = false;
|
|
50
|
+
try {
|
|
51
|
+
yes = (await isTreasury(address)) === true;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
yes = false;
|
|
55
|
+
}
|
|
56
|
+
if (!yes)
|
|
57
|
+
return refuse(code, address);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { ok: true };
|
|
61
|
+
}
|
|
62
|
+
/** `checkTreasuryParties`, throwing `NotATreasuryError` on refusal. */
|
|
63
|
+
export async function assertTreasuryParties(deps, parties) {
|
|
64
|
+
const c = await checkTreasuryParties(deps, parties);
|
|
65
|
+
if (!c.ok)
|
|
66
|
+
throw new NotATreasuryError(c.code, c.address);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=treasury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,CAAC,MAAM,IAAI,EAAE,EAAE,oBAAoB,CAAC;QAC5C,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,oBAAoB,CAAC;KACpC,EAAE,CAAC;QACX,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;YAC3B,IAAI,GAAG,GAAG,KAAK,CAAC;YAChB,IAAI,CAAC;gBACH,GAAG,GAAG,CAAC,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACP,GAAG,GAAG,KAAK,CAAC;YACd,CAAC;YACD,IAAI,CAAC,GAAG;gBAAE,OAAO,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAAuC,EACvC,OAAqE;IAErE,MAAM,CAAC,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpD,IAAI,CAAC,CAAC,CAAC,EAAE;QAAE,MAAM,IAAI,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenticprimitives/payments",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.43",
|
|
4
4
|
"description": "PaymentMandate + ContextBinding + MandateConstraints + open/closed mode discrimination. Three W1 rails (x402, wallet, sponsored-userop). PaymentReceipt asserted into AttestationRegistry per ADR-0023.",
|
|
5
5
|
"homepage": "https://agenticprimitives.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@noble/hashes": "^2.2.0",
|
|
56
56
|
"@noble/curves": "^2.2.0",
|
|
57
|
-
"@agenticprimitives/attestations": "0.0.0-alpha.
|
|
58
|
-
"@agenticprimitives/delegation": "1.0.0-alpha.
|
|
59
|
-
"@agenticprimitives/types": "1.0.0-alpha.
|
|
60
|
-
"@agenticprimitives/verifiable-credentials": "0.0.0-alpha.
|
|
57
|
+
"@agenticprimitives/attestations": "0.0.0-alpha.43",
|
|
58
|
+
"@agenticprimitives/delegation": "1.0.0-alpha.47",
|
|
59
|
+
"@agenticprimitives/types": "1.0.0-alpha.47",
|
|
60
|
+
"@agenticprimitives/verifiable-credentials": "0.0.0-alpha.44"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsc -p tsconfig.build.json",
|