@cmdoss/suipay 0.1.1-dev.0 → 0.1.1-dev.2
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/index.js +50 -25
- package/package.json +8 -5
package/dist/index.js
CHANGED
|
@@ -393,6 +393,32 @@ function createSpendAccountChain(options) {
|
|
|
393
393
|
kindBytes: toBase64(await tx.build({ client, onlyTransactionKind: true }))
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
|
+
function appendCreatePolicyGrant(tx, input) {
|
|
397
|
+
if (!input.onChainPolicyIds.length) {
|
|
398
|
+
throw new Error("create_grant requires at least one on-chain policy id");
|
|
399
|
+
}
|
|
400
|
+
if (!input.maxPerPayment || BigInt(input.maxPerPayment) <= 0n) {
|
|
401
|
+
throw new Error("create_grant requires a non-zero max_per_payment");
|
|
402
|
+
}
|
|
403
|
+
if (!input.sessionCap || BigInt(input.sessionCap) <= 0n) {
|
|
404
|
+
throw new Error("create_grant requires a non-zero session_cap");
|
|
405
|
+
}
|
|
406
|
+
const expires = input.expiresAtMs === void 0 || input.expiresAtMs === null ? 0n : BigInt(input.expiresAtMs);
|
|
407
|
+
tx.moveCall({
|
|
408
|
+
target: target("create_policy_grant"),
|
|
409
|
+
typeArguments: [input.coinType],
|
|
410
|
+
arguments: [
|
|
411
|
+
tx.object(input.poolObjectId),
|
|
412
|
+
tx.pure.address(input.delegate),
|
|
413
|
+
// The unified Grant<T> takes Option<u64> caps. This builder rejects
|
|
414
|
+
// absent or zero caps above, so both are always Some here.
|
|
415
|
+
tx.pure.option("u64", BigInt(input.sessionCap)),
|
|
416
|
+
tx.pure.option("u64", BigInt(input.maxPerPayment)),
|
|
417
|
+
tx.pure.u64(expires),
|
|
418
|
+
tx.pure.vector("u64", input.onChainPolicyIds.map((id) => BigInt(id)))
|
|
419
|
+
]
|
|
420
|
+
});
|
|
421
|
+
}
|
|
396
422
|
async function fundingCoin(tx, owner, coinType, amount) {
|
|
397
423
|
if (!isSuiCoinType(coinType)) {
|
|
398
424
|
return coinWithBalance({ type: coinType, balance: amount });
|
|
@@ -592,32 +618,23 @@ function createSpendAccountChain(options) {
|
|
|
592
618
|
return kindBytes(tx);
|
|
593
619
|
},
|
|
594
620
|
async buildCreateGrantKind(input) {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
621
|
+
const tx = new Transaction2();
|
|
622
|
+
tx.setSender(input.owner);
|
|
623
|
+
appendCreatePolicyGrant(tx, input);
|
|
624
|
+
return kindBytes(tx);
|
|
625
|
+
},
|
|
626
|
+
async buildCreateGrantBatchKind(inputs) {
|
|
627
|
+
if (!inputs.length) {
|
|
628
|
+
throw new Error("create_grant batch requires at least one grant");
|
|
600
629
|
}
|
|
601
|
-
|
|
602
|
-
|
|
630
|
+
const owner = inputs[0].owner;
|
|
631
|
+
if (inputs.some((input) => input.owner !== owner)) {
|
|
632
|
+
throw new Error("create_grant batch requires one owner");
|
|
603
633
|
}
|
|
604
634
|
const tx = new Transaction2();
|
|
605
|
-
tx.setSender(
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
target: target("create_policy_grant"),
|
|
609
|
-
typeArguments: [input.coinType],
|
|
610
|
-
arguments: [
|
|
611
|
-
tx.object(input.poolObjectId),
|
|
612
|
-
tx.pure.address(input.delegate),
|
|
613
|
-
// The unified Grant<T> takes Option<u64> caps. This builder rejects
|
|
614
|
-
// absent or zero caps above, so both are always Some here.
|
|
615
|
-
tx.pure.option("u64", BigInt(input.sessionCap)),
|
|
616
|
-
tx.pure.option("u64", BigInt(input.maxPerPayment)),
|
|
617
|
-
tx.pure.u64(expires),
|
|
618
|
-
tx.pure.vector("u64", input.onChainPolicyIds.map((id) => BigInt(id)))
|
|
619
|
-
]
|
|
620
|
-
});
|
|
635
|
+
tx.setSender(owner);
|
|
636
|
+
for (const input of inputs)
|
|
637
|
+
appendCreatePolicyGrant(tx, input);
|
|
621
638
|
return kindBytes(tx);
|
|
622
639
|
},
|
|
623
640
|
async buildCreateSpendGrantKind(input) {
|
|
@@ -6291,7 +6308,7 @@ var SECRET_KEY_SET = new Set(FORBIDDEN_SECRET_KEYS.map((k) => k.toLowerCase()));
|
|
|
6291
6308
|
|
|
6292
6309
|
// ../sdk/dist/agent-sdk/delegate-agent.js
|
|
6293
6310
|
function resolveExclusionDirectoryId(explicit, discovered) {
|
|
6294
|
-
return explicit
|
|
6311
|
+
return explicit?.trim() ? explicit : discovered;
|
|
6295
6312
|
}
|
|
6296
6313
|
function createExclusionRegistryResolver(client, exclusionDirectoryObjectId) {
|
|
6297
6314
|
if (!exclusionDirectoryObjectId || !exclusionDirectoryObjectId.trim())
|
|
@@ -6361,7 +6378,15 @@ async function createPayer(options) {
|
|
|
6361
6378
|
const { session, binding } = resolved.value;
|
|
6362
6379
|
const deployment = {
|
|
6363
6380
|
network: session.network,
|
|
6364
|
-
packageId: session.packageId
|
|
6381
|
+
packageId: session.packageId,
|
|
6382
|
+
// What the GATEWAY published, not what this payer settled on: a caller
|
|
6383
|
+
// override belongs to the payer's configuration, not to the deployment it
|
|
6384
|
+
// is describing. Dropping this left the field permanently undefined on the
|
|
6385
|
+
// one instance a consumer can reach, so anything asking the payer whether
|
|
6386
|
+
// guarded settles are available got "no" while it was doing them.
|
|
6387
|
+
...resolved.value.deployment.exclusionDirectoryObjectId ? {
|
|
6388
|
+
exclusionDirectoryObjectId: resolved.value.deployment.exclusionDirectoryObjectId
|
|
6389
|
+
} : {}
|
|
6365
6390
|
};
|
|
6366
6391
|
const exclusionDirectoryObjectId = resolveExclusionDirectoryId(options.exclusionDirectoryObjectId, resolved.value.deployment.exclusionDirectoryObjectId);
|
|
6367
6392
|
let network;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmdoss/suipay",
|
|
3
|
-
"version": "0.1.1-dev.
|
|
3
|
+
"version": "0.1.1-dev.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "SuiPay embeddable client
|
|
6
|
+
"description": "SuiPay embeddable client — quote and pay a 402 from a spend-account grant.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=20"
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"publishConfig": {
|
|
24
|
-
"access": "public"
|
|
24
|
+
"access": "public",
|
|
25
|
+
"provenance": false
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@mysten/sui": "2.24.0"
|
|
@@ -30,11 +31,13 @@
|
|
|
30
31
|
"@types/node": "^26",
|
|
31
32
|
"tsup": "^8.0.0",
|
|
32
33
|
"typescript": "^6.0.3",
|
|
33
|
-
"vitest": "^4.1.10"
|
|
34
|
+
"vitest": "^4.1.10",
|
|
35
|
+
"@cmdoss/suipay-core": "0.1.0",
|
|
36
|
+
"@cmdoss/suipay-sdk": "0.1.0"
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
39
|
"build": "tsup",
|
|
37
40
|
"test": "vitest run",
|
|
38
41
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
39
42
|
}
|
|
40
|
-
}
|
|
43
|
+
}
|