@mysten-incubation/suipay 0.2.0-dev.0 → 0.2.0-dev.10
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 +101 -1
- package/dist/index.js +421 -2
- package/package.json +3 -3
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;
|
|
@@ -448,7 +459,7 @@ declare const ERRORS: {
|
|
|
448
459
|
readonly logOnly: true;
|
|
449
460
|
};
|
|
450
461
|
readonly 'service.config_degraded': {
|
|
451
|
-
readonly surfaces: readonly ["gateway"];
|
|
462
|
+
readonly surfaces: readonly ["gateway", "console_server"];
|
|
452
463
|
readonly status: null;
|
|
453
464
|
readonly title: "Service started with degraded configuration";
|
|
454
465
|
readonly paymentState: "not_charged";
|
|
@@ -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;
|
|
@@ -467,6 +488,36 @@ declare const ERRORS: {
|
|
|
467
488
|
readonly user: null;
|
|
468
489
|
readonly logOnly: true;
|
|
469
490
|
};
|
|
491
|
+
readonly 'service.boot': {
|
|
492
|
+
readonly surfaces: readonly ["gateway", "seller", "indexer"];
|
|
493
|
+
readonly status: null;
|
|
494
|
+
readonly title: "Service started";
|
|
495
|
+
readonly paymentState: "not_charged";
|
|
496
|
+
readonly retry: "never";
|
|
497
|
+
readonly nextAction: "none";
|
|
498
|
+
readonly user: null;
|
|
499
|
+
readonly logOnly: true;
|
|
500
|
+
};
|
|
501
|
+
readonly 'service.lifecycle': {
|
|
502
|
+
readonly surfaces: readonly ["gateway", "seller", "indexer"];
|
|
503
|
+
readonly status: null;
|
|
504
|
+
readonly title: "Background work progressed";
|
|
505
|
+
readonly paymentState: "not_charged";
|
|
506
|
+
readonly retry: "never";
|
|
507
|
+
readonly nextAction: "none";
|
|
508
|
+
readonly user: null;
|
|
509
|
+
readonly logOnly: true;
|
|
510
|
+
};
|
|
511
|
+
readonly 'service.diagnostic': {
|
|
512
|
+
readonly surfaces: readonly ["gateway", "seller", "indexer"];
|
|
513
|
+
readonly status: null;
|
|
514
|
+
readonly title: "Diagnostic detail";
|
|
515
|
+
readonly paymentState: "not_charged";
|
|
516
|
+
readonly retry: "never";
|
|
517
|
+
readonly nextAction: "none";
|
|
518
|
+
readonly user: null;
|
|
519
|
+
readonly logOnly: true;
|
|
520
|
+
};
|
|
470
521
|
readonly 'limit.concurrency_exceeded': {
|
|
471
522
|
readonly surfaces: readonly ["gateway"];
|
|
472
523
|
readonly status: 429;
|
|
@@ -2664,6 +2715,55 @@ declare const ERRORS: {
|
|
|
2664
2715
|
readonly message: "That web address doesn't exist. Check the spelling and try again.";
|
|
2665
2716
|
};
|
|
2666
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
|
+
};
|
|
2667
2767
|
readonly 'request.redirect_refused': {
|
|
2668
2768
|
readonly surfaces: readonly ["console_server", "sdk"];
|
|
2669
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,
|
|
@@ -2073,7 +2133,7 @@ var SERVICE_CODES = {
|
|
|
2073
2133
|
},
|
|
2074
2134
|
// Boot or configuration fell back to a degraded mode instead of failing.
|
|
2075
2135
|
"service.config_degraded": {
|
|
2076
|
-
surfaces: ["gateway"],
|
|
2136
|
+
surfaces: ["gateway", "console_server"],
|
|
2077
2137
|
status: null,
|
|
2078
2138
|
title: "Service started with degraded configuration",
|
|
2079
2139
|
paymentState: "not_charged",
|
|
@@ -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": {
|
|
@@ -2093,6 +2166,39 @@ var SERVICE_CODES = {
|
|
|
2093
2166
|
nextAction: "none",
|
|
2094
2167
|
user: null,
|
|
2095
2168
|
logOnly: true
|
|
2169
|
+
},
|
|
2170
|
+
// What a process started with: network, posture, rails, gas pool. Healthy.
|
|
2171
|
+
"service.boot": {
|
|
2172
|
+
surfaces: ["gateway", "seller", "indexer"],
|
|
2173
|
+
status: null,
|
|
2174
|
+
title: "Service started",
|
|
2175
|
+
paymentState: "not_charged",
|
|
2176
|
+
retry: "never",
|
|
2177
|
+
nextAction: "none",
|
|
2178
|
+
user: null,
|
|
2179
|
+
logOnly: true
|
|
2180
|
+
},
|
|
2181
|
+
// A background worker started, stopped, swept or retried on schedule. Healthy.
|
|
2182
|
+
"service.lifecycle": {
|
|
2183
|
+
surfaces: ["gateway", "seller", "indexer"],
|
|
2184
|
+
status: null,
|
|
2185
|
+
title: "Background work progressed",
|
|
2186
|
+
paymentState: "not_charged",
|
|
2187
|
+
retry: "never",
|
|
2188
|
+
nextAction: "none",
|
|
2189
|
+
user: null,
|
|
2190
|
+
logOnly: true
|
|
2191
|
+
},
|
|
2192
|
+
// Detail about healthy traffic an operator may want when reading a trace.
|
|
2193
|
+
"service.diagnostic": {
|
|
2194
|
+
surfaces: ["gateway", "seller", "indexer"],
|
|
2195
|
+
status: null,
|
|
2196
|
+
title: "Diagnostic detail",
|
|
2197
|
+
paymentState: "not_charged",
|
|
2198
|
+
retry: "never",
|
|
2199
|
+
nextAction: "none",
|
|
2200
|
+
user: null,
|
|
2201
|
+
logOnly: true
|
|
2096
2202
|
}
|
|
2097
2203
|
};
|
|
2098
2204
|
|
|
@@ -2793,6 +2899,238 @@ function newTraceId(randomBytes2 = cryptoRandomBytes) {
|
|
|
2793
2899
|
return /^0+$/.test(hex) ? newTraceId(randomBytes2) : hex;
|
|
2794
2900
|
}
|
|
2795
2901
|
|
|
2902
|
+
// ../core/dist/errors/context-allowlist.js
|
|
2903
|
+
var CONTEXT_ALLOWLIST = /* @__PURE__ */ new Set([
|
|
2904
|
+
// Settlement and request identifiers.
|
|
2905
|
+
"txDigest",
|
|
2906
|
+
"digest",
|
|
2907
|
+
"challengeId",
|
|
2908
|
+
"paymentId",
|
|
2909
|
+
"paymentHash",
|
|
2910
|
+
"paymentKey",
|
|
2911
|
+
"paymentState",
|
|
2912
|
+
"requestId",
|
|
2913
|
+
"traceId",
|
|
2914
|
+
"clientId",
|
|
2915
|
+
"serviceId",
|
|
2916
|
+
"configId",
|
|
2917
|
+
"seedId",
|
|
2918
|
+
"grantId",
|
|
2919
|
+
"grantObjectId",
|
|
2920
|
+
"sameGrantObjectId",
|
|
2921
|
+
"verifiedGrant",
|
|
2922
|
+
"poolObjectId",
|
|
2923
|
+
"packageId",
|
|
2924
|
+
"activePackageId",
|
|
2925
|
+
"expectedPackageId",
|
|
2926
|
+
"actualPackageId",
|
|
2927
|
+
"mandateId",
|
|
2928
|
+
"session",
|
|
2929
|
+
"coinId",
|
|
2930
|
+
"coinIds",
|
|
2931
|
+
"id",
|
|
2932
|
+
"dedupeKey",
|
|
2933
|
+
"hook",
|
|
2934
|
+
// Addresses (public on chain).
|
|
2935
|
+
"owner",
|
|
2936
|
+
"payTo",
|
|
2937
|
+
"recipient",
|
|
2938
|
+
"delegateAddress",
|
|
2939
|
+
// Codes, kinds and states.
|
|
2940
|
+
"code",
|
|
2941
|
+
"innerCode",
|
|
2942
|
+
"requestedCode",
|
|
2943
|
+
"failureCode",
|
|
2944
|
+
"oauthError",
|
|
2945
|
+
"errorKind",
|
|
2946
|
+
"kind",
|
|
2947
|
+
"mode",
|
|
2948
|
+
"effectiveMode",
|
|
2949
|
+
"state",
|
|
2950
|
+
"outcome",
|
|
2951
|
+
"status",
|
|
2952
|
+
"httpStatus",
|
|
2953
|
+
"reason",
|
|
2954
|
+
"action",
|
|
2955
|
+
"stage",
|
|
2956
|
+
"paid",
|
|
2957
|
+
"delivery",
|
|
2958
|
+
"sellerStatus",
|
|
2959
|
+
"sellerCode",
|
|
2960
|
+
"bindingCode",
|
|
2961
|
+
"errorName",
|
|
2962
|
+
"gasStationStatus",
|
|
2963
|
+
"readFailure",
|
|
2964
|
+
"refusal",
|
|
2965
|
+
"refusedAs",
|
|
2966
|
+
"registryCode",
|
|
2967
|
+
"sessionDecision",
|
|
2968
|
+
"settleCode",
|
|
2969
|
+
"signedRequest",
|
|
2970
|
+
"signerCode",
|
|
2971
|
+
"consentCode",
|
|
2972
|
+
"publicReason",
|
|
2973
|
+
"details",
|
|
2974
|
+
"event",
|
|
2975
|
+
"eventType",
|
|
2976
|
+
"surface",
|
|
2977
|
+
"scope",
|
|
2978
|
+
"field",
|
|
2979
|
+
"header",
|
|
2980
|
+
"dependency",
|
|
2981
|
+
"network",
|
|
2982
|
+
"rails",
|
|
2983
|
+
"shard",
|
|
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",
|
|
2990
|
+
"alarm",
|
|
2991
|
+
"alert",
|
|
2992
|
+
"from",
|
|
2993
|
+
"to",
|
|
2994
|
+
"expected",
|
|
2995
|
+
"required",
|
|
2996
|
+
"violated",
|
|
2997
|
+
"diverged",
|
|
2998
|
+
"replaced",
|
|
2999
|
+
"suppressed",
|
|
3000
|
+
"unknown",
|
|
3001
|
+
"verified",
|
|
3002
|
+
"verification",
|
|
3003
|
+
"simulation",
|
|
3004
|
+
"isNew",
|
|
3005
|
+
"needsTopup",
|
|
3006
|
+
"operatorCapSet",
|
|
3007
|
+
"wantAgent",
|
|
3008
|
+
"wantGrant",
|
|
3009
|
+
"wantPool",
|
|
3010
|
+
"limitedBy",
|
|
3011
|
+
"peer",
|
|
3012
|
+
// Counts, amounts and timings.
|
|
3013
|
+
"amount",
|
|
3014
|
+
"scanned",
|
|
3015
|
+
"deleted",
|
|
3016
|
+
"intents",
|
|
3017
|
+
"policies",
|
|
3018
|
+
"connections",
|
|
3019
|
+
"events",
|
|
3020
|
+
"maxQueueSize",
|
|
3021
|
+
"bytes",
|
|
3022
|
+
"sha256",
|
|
3023
|
+
"ts",
|
|
3024
|
+
"count",
|
|
3025
|
+
"countRaw",
|
|
3026
|
+
"matchingCount",
|
|
3027
|
+
"registry_field_count",
|
|
3028
|
+
"applied",
|
|
3029
|
+
"attempt",
|
|
3030
|
+
"attempts",
|
|
3031
|
+
"cap",
|
|
3032
|
+
"max",
|
|
3033
|
+
"maxChallenges",
|
|
3034
|
+
"MAX_GAS_COIN_PAGES",
|
|
3035
|
+
"pagesScanned",
|
|
3036
|
+
"size",
|
|
3037
|
+
"free",
|
|
3038
|
+
"used",
|
|
3039
|
+
"fill",
|
|
3040
|
+
"limits",
|
|
3041
|
+
"refills",
|
|
3042
|
+
"refilled",
|
|
3043
|
+
"split",
|
|
3044
|
+
"unconfirmed",
|
|
3045
|
+
"spent",
|
|
3046
|
+
"reserveAfter",
|
|
3047
|
+
"claimedUntilMs",
|
|
3048
|
+
"repaired",
|
|
3049
|
+
"splits",
|
|
3050
|
+
"spend",
|
|
3051
|
+
"reserve",
|
|
3052
|
+
"reserveBalance",
|
|
3053
|
+
"ownerDailyMist",
|
|
3054
|
+
"ownerHourlyMist",
|
|
3055
|
+
"ownerIdentityDailyMist",
|
|
3056
|
+
"delegateDailyMist",
|
|
3057
|
+
"delegateHourlyMist",
|
|
3058
|
+
"delegateIdentityDailyMist",
|
|
3059
|
+
"consecutiveFailures",
|
|
3060
|
+
"failuresInARow",
|
|
3061
|
+
"epochReadFailures",
|
|
3062
|
+
"daysRemaining",
|
|
3063
|
+
"deadline",
|
|
3064
|
+
"delay",
|
|
3065
|
+
"delayMs",
|
|
3066
|
+
"ageMs",
|
|
3067
|
+
"timeoutMs",
|
|
3068
|
+
"nowMs",
|
|
3069
|
+
"switchedAtMs",
|
|
3070
|
+
"observeUntil",
|
|
3071
|
+
"window",
|
|
3072
|
+
"checkpointSeq",
|
|
3073
|
+
"eventSeq",
|
|
3074
|
+
"sampleSubjects",
|
|
3075
|
+
// Operator-facing error text. Redacted and length-capped like every string.
|
|
3076
|
+
"error",
|
|
3077
|
+
"errors",
|
|
3078
|
+
"err",
|
|
3079
|
+
"lastError",
|
|
3080
|
+
"outcomeError",
|
|
3081
|
+
"detail",
|
|
3082
|
+
"raw",
|
|
3083
|
+
"value"
|
|
3084
|
+
]);
|
|
3085
|
+
var MAX_CONTEXT_STRING = 512;
|
|
3086
|
+
var MAX_CONTEXT_ARRAY = 32;
|
|
3087
|
+
var MAX_CONTEXT_DEPTH = 4;
|
|
3088
|
+
function filterContext(context) {
|
|
3089
|
+
let dropped = 0;
|
|
3090
|
+
const filterValue = (value2, depth) => {
|
|
3091
|
+
if (typeof value2 === "bigint")
|
|
3092
|
+
return value2.toString();
|
|
3093
|
+
if (value2 === null || typeof value2 !== "object")
|
|
3094
|
+
return value2;
|
|
3095
|
+
if (depth >= MAX_CONTEXT_DEPTH) {
|
|
3096
|
+
dropped += 1;
|
|
3097
|
+
return void 0;
|
|
3098
|
+
}
|
|
3099
|
+
if (Array.isArray(value2)) {
|
|
3100
|
+
return value2.slice(0, MAX_CONTEXT_ARRAY).map((item) => filterValue(item, depth + 1));
|
|
3101
|
+
}
|
|
3102
|
+
if (value2 instanceof Date)
|
|
3103
|
+
return value2.toISOString();
|
|
3104
|
+
return filterObject(value2, depth + 1);
|
|
3105
|
+
};
|
|
3106
|
+
const filterObject = (object, depth) => {
|
|
3107
|
+
const out = {};
|
|
3108
|
+
for (const [key, value2] of Object.entries(object)) {
|
|
3109
|
+
if (!CONTEXT_ALLOWLIST.has(key)) {
|
|
3110
|
+
dropped += 1;
|
|
3111
|
+
continue;
|
|
3112
|
+
}
|
|
3113
|
+
const kept = filterValue(value2, depth);
|
|
3114
|
+
if (kept !== void 0)
|
|
3115
|
+
out[key] = kept;
|
|
3116
|
+
}
|
|
3117
|
+
return out;
|
|
3118
|
+
};
|
|
3119
|
+
const value = filterObject(context, 0);
|
|
3120
|
+
return { value, dropped };
|
|
3121
|
+
}
|
|
3122
|
+
function capContextStrings(value) {
|
|
3123
|
+
if (typeof value === "string") {
|
|
3124
|
+
return value.length > MAX_CONTEXT_STRING ? `${value.slice(0, MAX_CONTEXT_STRING)}\u2026` : value;
|
|
3125
|
+
}
|
|
3126
|
+
if (Array.isArray(value))
|
|
3127
|
+
return value.map(capContextStrings);
|
|
3128
|
+
if (value !== null && typeof value === "object") {
|
|
3129
|
+
return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, capContextStrings(v)]));
|
|
3130
|
+
}
|
|
3131
|
+
return value;
|
|
3132
|
+
}
|
|
3133
|
+
|
|
2796
3134
|
// ../core/dist/errors/log.js
|
|
2797
3135
|
var MAX_CAUSE_DEPTH = 5;
|
|
2798
3136
|
function causeChain(error) {
|
|
@@ -2843,6 +3181,7 @@ function safeStringify(value) {
|
|
|
2843
3181
|
function errorLogLine(context, error, now = /* @__PURE__ */ new Date()) {
|
|
2844
3182
|
const wantStack = context.withStack ?? (context.httpStatus !== void 0 && context.httpStatus >= 500);
|
|
2845
3183
|
const stack = wantStack && error instanceof Error && error.stack ? redactSecrets(error.stack) : void 0;
|
|
3184
|
+
const filtered = context.context ? filterContext(context.context) : void 0;
|
|
2846
3185
|
return {
|
|
2847
3186
|
level: context.level ?? "error",
|
|
2848
3187
|
time: now.toISOString(),
|
|
@@ -2854,10 +3193,12 @@ function errorLogLine(context, error, now = /* @__PURE__ */ new Date()) {
|
|
|
2854
3193
|
trace_id: context.traceId || newTraceId(),
|
|
2855
3194
|
cause: error === void 0 ? [] : causeChain(error),
|
|
2856
3195
|
...stack ? { stack } : {},
|
|
2857
|
-
...
|
|
3196
|
+
...filtered ? { context: capContextStrings(redactValue(filtered.value)) } : {},
|
|
3197
|
+
...filtered && filtered.dropped > 0 ? { context_dropped: filtered.dropped } : {}
|
|
2858
3198
|
};
|
|
2859
3199
|
}
|
|
2860
3200
|
var stderrWriter = (line) => console.error(line);
|
|
3201
|
+
var lineShipper = null;
|
|
2861
3202
|
function logError(context, error, write = stderrWriter) {
|
|
2862
3203
|
let line;
|
|
2863
3204
|
let traceId = "";
|
|
@@ -2878,6 +3219,12 @@ function logError(context, error, write = stderrWriter) {
|
|
|
2878
3219
|
write(line);
|
|
2879
3220
|
} catch {
|
|
2880
3221
|
}
|
|
3222
|
+
if (write === stderrWriter && lineShipper) {
|
|
3223
|
+
try {
|
|
3224
|
+
lineShipper.enqueue(line, context.level ?? "error");
|
|
3225
|
+
} catch {
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
2881
3228
|
}
|
|
2882
3229
|
|
|
2883
3230
|
// ../core/dist/errors/suipay-error.js
|
|
@@ -3340,6 +3687,14 @@ var SERVICE_STATE_TRANSITIONS = Object.freeze([
|
|
|
3340
3687
|
to: "payout_change",
|
|
3341
3688
|
actors: ["system"],
|
|
3342
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"]
|
|
3343
3698
|
}
|
|
3344
3699
|
]);
|
|
3345
3700
|
|
|
@@ -3739,6 +4094,70 @@ function createSpendAccountChain(options) {
|
|
|
3739
4094
|
});
|
|
3740
4095
|
return kindBytes(tx);
|
|
3741
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
|
+
},
|
|
3742
4161
|
async buildPausePolicyKind(input) {
|
|
3743
4162
|
const tx = new Transaction2();
|
|
3744
4163
|
tx.setSender(input.owner);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mysten-incubation/suipay",
|
|
3
|
-
"version": "0.2.0-dev.
|
|
3
|
+
"version": "0.2.0-dev.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "SuiPay embeddable client — quote and pay a 402 from a spend-account grant.",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"tsup": "^8.0.0",
|
|
38
38
|
"typescript": "^6.0.3",
|
|
39
39
|
"vitest": "^4.1.10",
|
|
40
|
-
"@cmdoss/suipay-
|
|
41
|
-
"@cmdoss/suipay-
|
|
40
|
+
"@cmdoss/suipay-sdk": "0.1.0",
|
|
41
|
+
"@cmdoss/suipay-core": "0.1.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsup",
|