@mysten-incubation/suipay 0.2.0-dev.1 → 0.2.0-dev.11
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.d.ts +70 -0
- package/dist/index.js +150 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,17 @@ declare const ERRORS: {
|
|
|
55
55
|
readonly user: null;
|
|
56
56
|
readonly logOnly: true;
|
|
57
57
|
};
|
|
58
|
+
readonly 'indexer.native_settlement_deferred': {
|
|
59
|
+
readonly surfaces: readonly ["indexer"];
|
|
60
|
+
readonly status: null;
|
|
61
|
+
readonly title: "Native settlement is deferred; holding the checkpoint";
|
|
62
|
+
readonly paymentState: "not_charged";
|
|
63
|
+
readonly retry: "after_delay";
|
|
64
|
+
readonly retryAfterSeconds: 5;
|
|
65
|
+
readonly nextAction: "retry_later";
|
|
66
|
+
readonly user: null;
|
|
67
|
+
readonly logOnly: true;
|
|
68
|
+
};
|
|
58
69
|
readonly 'indexer.config_invalid': {
|
|
59
70
|
readonly surfaces: readonly ["indexer"];
|
|
60
71
|
readonly status: null;
|
|
@@ -457,6 +468,16 @@ declare const ERRORS: {
|
|
|
457
468
|
readonly user: null;
|
|
458
469
|
readonly logOnly: true;
|
|
459
470
|
};
|
|
471
|
+
readonly 'service.readiness': {
|
|
472
|
+
readonly surfaces: readonly ["gateway"];
|
|
473
|
+
readonly status: null;
|
|
474
|
+
readonly title: "Readiness gauge updated";
|
|
475
|
+
readonly paymentState: "not_charged";
|
|
476
|
+
readonly retry: "never";
|
|
477
|
+
readonly nextAction: "none";
|
|
478
|
+
readonly user: null;
|
|
479
|
+
readonly logOnly: true;
|
|
480
|
+
};
|
|
460
481
|
readonly 'service.bookkeeping_failed': {
|
|
461
482
|
readonly surfaces: readonly ["gateway"];
|
|
462
483
|
readonly status: null;
|
|
@@ -2694,6 +2715,55 @@ declare const ERRORS: {
|
|
|
2694
2715
|
readonly message: "That web address doesn't exist. Check the spelling and try again.";
|
|
2695
2716
|
};
|
|
2696
2717
|
};
|
|
2718
|
+
readonly 'request.recipient_changed': {
|
|
2719
|
+
readonly surfaces: readonly ["gateway"];
|
|
2720
|
+
readonly status: 409;
|
|
2721
|
+
readonly title: "Pay-to address changed while its registry was being checked";
|
|
2722
|
+
readonly paymentState: "not_charged";
|
|
2723
|
+
readonly retry: "never";
|
|
2724
|
+
readonly nextAction: "fix_request";
|
|
2725
|
+
readonly user: {
|
|
2726
|
+
readonly title: "Retry this publish";
|
|
2727
|
+
readonly message: "The payout address changed while its payment registry was being checked. Retry so the current address is checked.";
|
|
2728
|
+
};
|
|
2729
|
+
};
|
|
2730
|
+
readonly 'request.recipient_registry_invalid': {
|
|
2731
|
+
readonly surfaces: readonly ["gateway"];
|
|
2732
|
+
readonly status: 409;
|
|
2733
|
+
readonly title: "Payment registry does not verify for this deployment";
|
|
2734
|
+
readonly paymentState: "not_charged";
|
|
2735
|
+
readonly retry: "never";
|
|
2736
|
+
readonly nextAction: "fix_request";
|
|
2737
|
+
readonly user: {
|
|
2738
|
+
readonly title: "Registry does not match";
|
|
2739
|
+
readonly message: "The payout address's payment registry does not match this deployment. Fix it, then publish again.";
|
|
2740
|
+
};
|
|
2741
|
+
};
|
|
2742
|
+
readonly 'request.recipient_registry_missing': {
|
|
2743
|
+
readonly surfaces: readonly ["gateway"];
|
|
2744
|
+
readonly status: 409;
|
|
2745
|
+
readonly title: "Pay-to address has no payment registry";
|
|
2746
|
+
readonly paymentState: "not_charged";
|
|
2747
|
+
readonly retry: "never";
|
|
2748
|
+
readonly nextAction: "fix_request";
|
|
2749
|
+
readonly user: {
|
|
2750
|
+
readonly title: "Create a payment registry";
|
|
2751
|
+
readonly message: "This payout address has no payment registry on this network yet. Create it in the seller console, then publish again.";
|
|
2752
|
+
};
|
|
2753
|
+
};
|
|
2754
|
+
readonly 'request.recipient_registry_unreadable': {
|
|
2755
|
+
readonly surfaces: readonly ["gateway"];
|
|
2756
|
+
readonly status: 503;
|
|
2757
|
+
readonly title: "Payment registry could not be read";
|
|
2758
|
+
readonly paymentState: "not_charged";
|
|
2759
|
+
readonly retry: "after_delay";
|
|
2760
|
+
readonly retryAfterSeconds: 5;
|
|
2761
|
+
readonly nextAction: "retry_later";
|
|
2762
|
+
readonly user: {
|
|
2763
|
+
readonly title: "Registry unread";
|
|
2764
|
+
readonly message: "The payment registry could not be read just now. Wait a moment and try again.";
|
|
2765
|
+
};
|
|
2766
|
+
};
|
|
2697
2767
|
readonly 'request.redirect_refused': {
|
|
2698
2768
|
readonly surfaces: readonly ["console_server", "sdk"];
|
|
2699
2769
|
readonly status: 422;
|
package/dist/index.js
CHANGED
|
@@ -1004,6 +1004,17 @@ var INDEXER_CODES = {
|
|
|
1004
1004
|
user: null,
|
|
1005
1005
|
logOnly: true
|
|
1006
1006
|
},
|
|
1007
|
+
"indexer.native_settlement_deferred": {
|
|
1008
|
+
surfaces: ["indexer"],
|
|
1009
|
+
status: null,
|
|
1010
|
+
title: "Native settlement is deferred; holding the checkpoint",
|
|
1011
|
+
paymentState: "not_charged",
|
|
1012
|
+
retry: "after_delay",
|
|
1013
|
+
retryAfterSeconds: 5,
|
|
1014
|
+
nextAction: "retry_later",
|
|
1015
|
+
user: null,
|
|
1016
|
+
logOnly: true
|
|
1017
|
+
},
|
|
1007
1018
|
"indexer.config_invalid": {
|
|
1008
1019
|
surfaces: ["indexer"],
|
|
1009
1020
|
status: null,
|
|
@@ -1618,6 +1629,55 @@ var REQUEST_CODES = {
|
|
|
1618
1629
|
nextAction: "fix_request",
|
|
1619
1630
|
user: { title: "Address not found", message: "That web address doesn't exist. Check the spelling and try again." }
|
|
1620
1631
|
},
|
|
1632
|
+
"request.recipient_changed": {
|
|
1633
|
+
surfaces: ["gateway"],
|
|
1634
|
+
status: 409,
|
|
1635
|
+
title: "Pay-to address changed while its registry was being checked",
|
|
1636
|
+
paymentState: "not_charged",
|
|
1637
|
+
retry: "never",
|
|
1638
|
+
nextAction: "fix_request",
|
|
1639
|
+
user: {
|
|
1640
|
+
title: "Retry this publish",
|
|
1641
|
+
message: "The payout address changed while its payment registry was being checked. Retry so the current address is checked."
|
|
1642
|
+
}
|
|
1643
|
+
},
|
|
1644
|
+
"request.recipient_registry_invalid": {
|
|
1645
|
+
surfaces: ["gateway"],
|
|
1646
|
+
status: 409,
|
|
1647
|
+
title: "Payment registry does not verify for this deployment",
|
|
1648
|
+
paymentState: "not_charged",
|
|
1649
|
+
retry: "never",
|
|
1650
|
+
nextAction: "fix_request",
|
|
1651
|
+
user: {
|
|
1652
|
+
title: "Registry does not match",
|
|
1653
|
+
message: "The payout address's payment registry does not match this deployment. Fix it, then publish again."
|
|
1654
|
+
}
|
|
1655
|
+
},
|
|
1656
|
+
"request.recipient_registry_missing": {
|
|
1657
|
+
surfaces: ["gateway"],
|
|
1658
|
+
status: 409,
|
|
1659
|
+
title: "Pay-to address has no payment registry",
|
|
1660
|
+
paymentState: "not_charged",
|
|
1661
|
+
retry: "never",
|
|
1662
|
+
nextAction: "fix_request",
|
|
1663
|
+
user: {
|
|
1664
|
+
title: "Create a payment registry",
|
|
1665
|
+
message: "This payout address has no payment registry on this network yet. Create it in the seller console, then publish again."
|
|
1666
|
+
}
|
|
1667
|
+
},
|
|
1668
|
+
"request.recipient_registry_unreadable": {
|
|
1669
|
+
surfaces: ["gateway"],
|
|
1670
|
+
status: 503,
|
|
1671
|
+
title: "Payment registry could not be read",
|
|
1672
|
+
paymentState: "not_charged",
|
|
1673
|
+
retry: "after_delay",
|
|
1674
|
+
retryAfterSeconds: 5,
|
|
1675
|
+
nextAction: "retry_later",
|
|
1676
|
+
user: {
|
|
1677
|
+
title: "Registry unread",
|
|
1678
|
+
message: "The payment registry could not be read just now. Wait a moment and try again."
|
|
1679
|
+
}
|
|
1680
|
+
},
|
|
1621
1681
|
"request.redirect_refused": {
|
|
1622
1682
|
surfaces: ["console_server", "sdk"],
|
|
1623
1683
|
status: 422,
|
|
@@ -2082,6 +2142,19 @@ var SERVICE_CODES = {
|
|
|
2082
2142
|
user: null,
|
|
2083
2143
|
logOnly: true
|
|
2084
2144
|
},
|
|
2145
|
+
// A readiness gauge moved while the process is still serving. Not a degraded
|
|
2146
|
+
// boot: `service.config_degraded` is reserved for that, and for the sample
|
|
2147
|
+
// that actually fails closed.
|
|
2148
|
+
"service.readiness": {
|
|
2149
|
+
surfaces: ["gateway"],
|
|
2150
|
+
status: null,
|
|
2151
|
+
title: "Readiness gauge updated",
|
|
2152
|
+
paymentState: "not_charged",
|
|
2153
|
+
retry: "never",
|
|
2154
|
+
nextAction: "none",
|
|
2155
|
+
user: null,
|
|
2156
|
+
logOnly: true
|
|
2157
|
+
},
|
|
2085
2158
|
// A best-effort write (a trace event, a receipt, a delivery record) failed.
|
|
2086
2159
|
// The request it belongs to keeps its answer.
|
|
2087
2160
|
"service.bookkeeping_failed": {
|
|
@@ -2909,6 +2982,11 @@ var CONTEXT_ALLOWLIST = /* @__PURE__ */ new Set([
|
|
|
2909
2982
|
"rails",
|
|
2910
2983
|
"shard",
|
|
2911
2984
|
"metric",
|
|
2985
|
+
// Gateway readiness gauge. Fixed marks only: 0 or 1, and up, down, skipped, unknown.
|
|
2986
|
+
"ready",
|
|
2987
|
+
"grpc",
|
|
2988
|
+
"enoki",
|
|
2989
|
+
"postgres",
|
|
2912
2990
|
"alarm",
|
|
2913
2991
|
"alert",
|
|
2914
2992
|
"from",
|
|
@@ -3609,6 +3687,14 @@ var SERVICE_STATE_TRANSITIONS = Object.freeze([
|
|
|
3609
3687
|
to: "payout_change",
|
|
3610
3688
|
actors: ["system"],
|
|
3611
3689
|
requires: ["reason_code"]
|
|
3690
|
+
},
|
|
3691
|
+
{
|
|
3692
|
+
id: "T25",
|
|
3693
|
+
dimension: "suspension",
|
|
3694
|
+
from: ["binding_changed"],
|
|
3695
|
+
to: "none",
|
|
3696
|
+
actors: ["system"],
|
|
3697
|
+
requires: ["reason_code"]
|
|
3612
3698
|
}
|
|
3613
3699
|
]);
|
|
3614
3700
|
|
|
@@ -4008,6 +4094,70 @@ function createSpendAccountChain(options) {
|
|
|
4008
4094
|
});
|
|
4009
4095
|
return kindBytes(tx);
|
|
4010
4096
|
},
|
|
4097
|
+
async buildCreatePolicyAndGrantKind(input) {
|
|
4098
|
+
if (!input.policy.targets?.length) {
|
|
4099
|
+
throw new Error("create_spend_policy requires at least one target");
|
|
4100
|
+
}
|
|
4101
|
+
if (!input.policy.totalCap || BigInt(input.policy.totalCap) <= 0n) {
|
|
4102
|
+
throw new Error("create_spend_policy requires a non-zero total_cap");
|
|
4103
|
+
}
|
|
4104
|
+
if (!input.policy.maxPerPayment || BigInt(input.policy.maxPerPayment) <= 0n) {
|
|
4105
|
+
throw new Error("create_spend_policy requires a non-zero max_per_payment");
|
|
4106
|
+
}
|
|
4107
|
+
if (!input.grant.sessionCap || BigInt(input.grant.sessionCap) <= 0n) {
|
|
4108
|
+
throw new Error("create_grant requires a non-zero session_cap");
|
|
4109
|
+
}
|
|
4110
|
+
if (!input.grant.maxPerPayment || BigInt(input.grant.maxPerPayment) <= 0n) {
|
|
4111
|
+
throw new Error("create_grant requires a non-zero max_per_payment");
|
|
4112
|
+
}
|
|
4113
|
+
const tx = new Transaction2();
|
|
4114
|
+
tx.setSender(input.owner);
|
|
4115
|
+
const targetResults = input.policy.targets.map((t) => {
|
|
4116
|
+
const hash = targetHashBytes(t.targetHash);
|
|
4117
|
+
return tx.moveCall({
|
|
4118
|
+
target: target("new_policy_target"),
|
|
4119
|
+
arguments: [
|
|
4120
|
+
tx.pure.vector("u8", Array.from(hash)),
|
|
4121
|
+
tx.pure.address(t.recipient),
|
|
4122
|
+
tx.pure.u64(BigInt(t.maxPerPayment))
|
|
4123
|
+
]
|
|
4124
|
+
});
|
|
4125
|
+
});
|
|
4126
|
+
const targetsVec = tx.makeMoveVec({
|
|
4127
|
+
type: `${packageId}::${MODULE}::PolicyTarget`,
|
|
4128
|
+
elements: targetResults
|
|
4129
|
+
});
|
|
4130
|
+
const policyExpires = input.policy.expiresAtMs === void 0 || input.policy.expiresAtMs === null ? 0n : BigInt(input.policy.expiresAtMs);
|
|
4131
|
+
const policyIdResult = tx.moveCall({
|
|
4132
|
+
target: target("create_spend_policy"),
|
|
4133
|
+
typeArguments: [input.coinType],
|
|
4134
|
+
arguments: [
|
|
4135
|
+
tx.object(input.poolObjectId),
|
|
4136
|
+
targetsVec,
|
|
4137
|
+
tx.pure.u64(BigInt(input.policy.totalCap)),
|
|
4138
|
+
tx.pure.u64(BigInt(input.policy.maxPerPayment)),
|
|
4139
|
+
tx.pure.u64(policyExpires)
|
|
4140
|
+
]
|
|
4141
|
+
});
|
|
4142
|
+
const policyIdsVec = tx.makeMoveVec({
|
|
4143
|
+
type: "u64",
|
|
4144
|
+
elements: [policyIdResult]
|
|
4145
|
+
});
|
|
4146
|
+
const grantExpires = input.grant.expiresAtMs === void 0 || input.grant.expiresAtMs === null ? 0n : BigInt(input.grant.expiresAtMs);
|
|
4147
|
+
tx.moveCall({
|
|
4148
|
+
target: target("create_policy_grant"),
|
|
4149
|
+
typeArguments: [input.coinType],
|
|
4150
|
+
arguments: [
|
|
4151
|
+
tx.object(input.poolObjectId),
|
|
4152
|
+
tx.pure.address(input.delegate),
|
|
4153
|
+
tx.pure.option("u64", BigInt(input.grant.sessionCap)),
|
|
4154
|
+
tx.pure.option("u64", BigInt(input.grant.maxPerPayment)),
|
|
4155
|
+
tx.pure.u64(grantExpires),
|
|
4156
|
+
policyIdsVec
|
|
4157
|
+
]
|
|
4158
|
+
});
|
|
4159
|
+
return kindBytes(tx);
|
|
4160
|
+
},
|
|
4011
4161
|
async buildPausePolicyKind(input) {
|
|
4012
4162
|
const tx = new Transaction2();
|
|
4013
4163
|
tx.setSender(input.owner);
|