@certen.io/sdk 0.3.1 → 0.5.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/CHANGELOG.md +298 -139
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +46 -4
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +78 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +112 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/billing.d.ts +63 -0
- package/dist/resources/billing.d.ts.map +1 -0
- package/dist/resources/billing.js +86 -0
- package/dist/resources/billing.js.map +1 -0
- package/dist/resources/execute.d.ts +32 -2
- package/dist/resources/execute.d.ts.map +1 -1
- package/dist/resources/execute.js +35 -4
- package/dist/resources/execute.js.map +1 -1
- package/dist/types.d.ts +124 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +67 -67
package/dist/errors.d.ts
CHANGED
|
@@ -8,9 +8,19 @@ export declare class CertenError extends Error {
|
|
|
8
8
|
readonly code: string;
|
|
9
9
|
readonly requestId?: string;
|
|
10
10
|
readonly details?: unknown;
|
|
11
|
+
/**
|
|
12
|
+
* The gateway's parsed response body, when it sent one.
|
|
13
|
+
*
|
|
14
|
+
* Kept because some refusals carry the FIX and not just the diagnosis: a 402
|
|
15
|
+
* arrives with a live payment target, and discarding the body left the caller
|
|
16
|
+
* holding a message string. Undefined when the body was not JSON (an edge 502,
|
|
17
|
+
* an HTML error page) and when there was no response at all.
|
|
18
|
+
*/
|
|
19
|
+
readonly body?: unknown;
|
|
11
20
|
constructor(message: string, status: number, code: string, opts?: {
|
|
12
21
|
requestId?: string;
|
|
13
22
|
details?: unknown;
|
|
23
|
+
body?: unknown;
|
|
14
24
|
});
|
|
15
25
|
/** True for transient downstream errors that are safe to retry. */
|
|
16
26
|
get isRetryable(): boolean;
|
|
@@ -20,6 +30,7 @@ export declare class CertenError extends Error {
|
|
|
20
30
|
static fromAxios(message: string, status: number, code: string, opts?: {
|
|
21
31
|
requestId?: string;
|
|
22
32
|
details?: unknown;
|
|
33
|
+
body?: unknown;
|
|
23
34
|
}): CertenError;
|
|
24
35
|
}
|
|
25
36
|
export declare class CertenAuthError extends CertenError {
|
|
@@ -32,4 +43,71 @@ export declare class CertenBadRequestError extends CertenError {
|
|
|
32
43
|
}
|
|
33
44
|
export declare class CertenServerError extends CertenError {
|
|
34
45
|
}
|
|
46
|
+
/** A live way to settle a 402, minted by the gateway with the refusal. */
|
|
47
|
+
export interface PaymentResolution {
|
|
48
|
+
/** Reference the deposit is matched by. */
|
|
49
|
+
payment_intent: string;
|
|
50
|
+
chain: string;
|
|
51
|
+
to_address: string;
|
|
52
|
+
/** Send EXACTLY this. Attribution matches the amount, so a different one will not credit. */
|
|
53
|
+
amount_usd: string;
|
|
54
|
+
expires_at: string;
|
|
55
|
+
/** True when an already-open payment covered the shortfall and was reused. */
|
|
56
|
+
reused_existing: boolean;
|
|
57
|
+
portal_url: string;
|
|
58
|
+
cli_command: string;
|
|
59
|
+
note: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The account cannot pay for this work. HTTP 402.
|
|
63
|
+
*
|
|
64
|
+
* Distinct from `CertenBadRequestError` because nothing is wrong with the request
|
|
65
|
+
* — it is priced, valid, and would succeed once funded. A host product needs that
|
|
66
|
+
* distinction to decide between showing a top-up prompt and showing a validation
|
|
67
|
+
* error.
|
|
68
|
+
*
|
|
69
|
+
* Two codes arrive here and they need different remedies:
|
|
70
|
+
*
|
|
71
|
+
* PAYMENT_REQUIRED the balance does not cover this request. Add funds.
|
|
72
|
+
* COMMITMENT_EXCEEDED the balance would cover this request alone, but pending
|
|
73
|
+
* intents have already claimed it. Add funds OR wait for
|
|
74
|
+
* those to settle or expire — see `pendingIntents`.
|
|
75
|
+
*
|
|
76
|
+
* Never retried automatically, and never should be: the outcome cannot change
|
|
77
|
+
* until money moves, so a retry loop is just load.
|
|
78
|
+
*
|
|
79
|
+
* `resolution` is null when the gateway could not mint a target (no chain
|
|
80
|
+
* configured for deposits, for instance). The refusal is still valid; there is
|
|
81
|
+
* simply no one-step fix to offer, so fall back to `portalUrl` on your own UI.
|
|
82
|
+
*/
|
|
83
|
+
export declare class CertenPaymentRequiredError extends CertenError {
|
|
84
|
+
private get payload();
|
|
85
|
+
private nested;
|
|
86
|
+
private str;
|
|
87
|
+
/** True when pending commitments, not the raw balance, caused the refusal. */
|
|
88
|
+
get isCommitmentExceeded(): boolean;
|
|
89
|
+
/** How much more is needed, as a fixed-6dp decimal string. */
|
|
90
|
+
get shortfallUsd(): string | undefined;
|
|
91
|
+
get spendableUsd(): string | undefined;
|
|
92
|
+
/** Non-terminal intents that have already claimed balance. Commitment case only. */
|
|
93
|
+
get pendingIntents(): number | undefined;
|
|
94
|
+
/** Re-send the request with this to reuse the price you were quoted. */
|
|
95
|
+
get quoteId(): string | undefined;
|
|
96
|
+
/** After this, the quoted price is gone and the work must be re-quoted. */
|
|
97
|
+
get quoteExpiresAt(): string | undefined;
|
|
98
|
+
/** The payment target, or null when the gateway could not offer one. */
|
|
99
|
+
get resolution(): PaymentResolution | null;
|
|
100
|
+
/** Deep link for your own UI to send the customer to. */
|
|
101
|
+
get portalUrl(): string | undefined;
|
|
102
|
+
/** The exact command that settles this from a terminal. */
|
|
103
|
+
get cliCommand(): string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* One line fit to show a person, whichever code arrived.
|
|
106
|
+
*
|
|
107
|
+
* Provided so every host product does not re-derive the same sentence, and get
|
|
108
|
+
* the commitment case wrong by telling the customer to add funds when waiting
|
|
109
|
+
* would also work.
|
|
110
|
+
*/
|
|
111
|
+
get summary(): string;
|
|
112
|
+
}
|
|
35
113
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;;OAOG;IACH,SAAgB,IAAI,CAAC,EAAE,OAAO,CAAC;gBAG7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO;IAWtE,mEAAmE;IACnE,IAAI,WAAW,IAAI,OAAO,CAMzB;IAED,mEAAmE;IACnE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,gEAAgE;IAChE,MAAM,CAAC,SAAS,CACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAC/D,WAAW;CAWf;AAED,qBAAa,eAAgB,SAAQ,WAAW;CAAG;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CAEnC;IAED;;;;;;OAMG;IACH,IAAI,OAAO,IAAI,MAAM,CAUpB;CACF"}
|
package/dist/errors.js
CHANGED
|
@@ -8,6 +8,15 @@ export class CertenError extends Error {
|
|
|
8
8
|
code;
|
|
9
9
|
requestId;
|
|
10
10
|
details;
|
|
11
|
+
/**
|
|
12
|
+
* The gateway's parsed response body, when it sent one.
|
|
13
|
+
*
|
|
14
|
+
* Kept because some refusals carry the FIX and not just the diagnosis: a 402
|
|
15
|
+
* arrives with a live payment target, and discarding the body left the caller
|
|
16
|
+
* holding a message string. Undefined when the body was not JSON (an edge 502,
|
|
17
|
+
* an HTML error page) and when there was no response at all.
|
|
18
|
+
*/
|
|
19
|
+
body;
|
|
11
20
|
constructor(message, status, code, opts = {}) {
|
|
12
21
|
super(message);
|
|
13
22
|
this.name = 'CertenError';
|
|
@@ -15,6 +24,7 @@ export class CertenError extends Error {
|
|
|
15
24
|
this.code = code;
|
|
16
25
|
this.requestId = opts.requestId;
|
|
17
26
|
this.details = opts.details;
|
|
27
|
+
this.body = opts.body;
|
|
18
28
|
}
|
|
19
29
|
/** True for transient downstream errors that are safe to retry. */
|
|
20
30
|
get isRetryable() {
|
|
@@ -38,6 +48,11 @@ export class CertenError extends Error {
|
|
|
38
48
|
return new CertenAuthError(message, status, code, opts);
|
|
39
49
|
if (status === 429)
|
|
40
50
|
return new CertenRateLimitError(message, status, code, opts);
|
|
51
|
+
// Before the generic 4xx branch: a payment problem is not a malformed request,
|
|
52
|
+
// and a host product needs to tell those apart to know whether to show a
|
|
53
|
+
// "top up" prompt or a validation message.
|
|
54
|
+
if (status === 402)
|
|
55
|
+
return new CertenPaymentRequiredError(message, status, code, opts);
|
|
41
56
|
if (status >= 500)
|
|
42
57
|
return new CertenServerError(message, status, code, opts);
|
|
43
58
|
if (status >= 400)
|
|
@@ -58,4 +73,101 @@ export class CertenBadRequestError extends CertenError {
|
|
|
58
73
|
}
|
|
59
74
|
export class CertenServerError extends CertenError {
|
|
60
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The account cannot pay for this work. HTTP 402.
|
|
78
|
+
*
|
|
79
|
+
* Distinct from `CertenBadRequestError` because nothing is wrong with the request
|
|
80
|
+
* — it is priced, valid, and would succeed once funded. A host product needs that
|
|
81
|
+
* distinction to decide between showing a top-up prompt and showing a validation
|
|
82
|
+
* error.
|
|
83
|
+
*
|
|
84
|
+
* Two codes arrive here and they need different remedies:
|
|
85
|
+
*
|
|
86
|
+
* PAYMENT_REQUIRED the balance does not cover this request. Add funds.
|
|
87
|
+
* COMMITMENT_EXCEEDED the balance would cover this request alone, but pending
|
|
88
|
+
* intents have already claimed it. Add funds OR wait for
|
|
89
|
+
* those to settle or expire — see `pendingIntents`.
|
|
90
|
+
*
|
|
91
|
+
* Never retried automatically, and never should be: the outcome cannot change
|
|
92
|
+
* until money moves, so a retry loop is just load.
|
|
93
|
+
*
|
|
94
|
+
* `resolution` is null when the gateway could not mint a target (no chain
|
|
95
|
+
* configured for deposits, for instance). The refusal is still valid; there is
|
|
96
|
+
* simply no one-step fix to offer, so fall back to `portalUrl` on your own UI.
|
|
97
|
+
*/
|
|
98
|
+
export class CertenPaymentRequiredError extends CertenError {
|
|
99
|
+
get payload() {
|
|
100
|
+
return (typeof this.body === 'object' && this.body !== null)
|
|
101
|
+
? this.body
|
|
102
|
+
: {};
|
|
103
|
+
}
|
|
104
|
+
nested(key) {
|
|
105
|
+
const v = this.payload[key];
|
|
106
|
+
return (typeof v === 'object' && v !== null) ? v : {};
|
|
107
|
+
}
|
|
108
|
+
str(obj, key) {
|
|
109
|
+
const v = obj[key];
|
|
110
|
+
return typeof v === 'string' ? v : undefined;
|
|
111
|
+
}
|
|
112
|
+
/** True when pending commitments, not the raw balance, caused the refusal. */
|
|
113
|
+
get isCommitmentExceeded() {
|
|
114
|
+
return this.code === 'COMMITMENT_EXCEEDED';
|
|
115
|
+
}
|
|
116
|
+
/** How much more is needed, as a fixed-6dp decimal string. */
|
|
117
|
+
get shortfallUsd() {
|
|
118
|
+
return this.str(this.nested('balance'), 'shortfall_usd')
|
|
119
|
+
?? this.str(this.nested('commitments'), 'shortfall_usd');
|
|
120
|
+
}
|
|
121
|
+
get spendableUsd() {
|
|
122
|
+
return this.str(this.nested('balance'), 'spendable_usd');
|
|
123
|
+
}
|
|
124
|
+
/** Non-terminal intents that have already claimed balance. Commitment case only. */
|
|
125
|
+
get pendingIntents() {
|
|
126
|
+
const v = this.nested('commitments').pending_intents;
|
|
127
|
+
return typeof v === 'number' ? v : undefined;
|
|
128
|
+
}
|
|
129
|
+
/** Re-send the request with this to reuse the price you were quoted. */
|
|
130
|
+
get quoteId() {
|
|
131
|
+
return this.str(this.nested('quote'), 'id');
|
|
132
|
+
}
|
|
133
|
+
/** After this, the quoted price is gone and the work must be re-quoted. */
|
|
134
|
+
get quoteExpiresAt() {
|
|
135
|
+
return this.str(this.nested('quote'), 'expires_at')
|
|
136
|
+
?? this.str(this.payload, 'quote_expires_at');
|
|
137
|
+
}
|
|
138
|
+
/** The payment target, or null when the gateway could not offer one. */
|
|
139
|
+
get resolution() {
|
|
140
|
+
const r = this.payload.resolve;
|
|
141
|
+
if (typeof r !== 'object' || r === null)
|
|
142
|
+
return null;
|
|
143
|
+
const o = r;
|
|
144
|
+
return typeof o.payment_intent === 'string' ? r : null;
|
|
145
|
+
}
|
|
146
|
+
/** Deep link for your own UI to send the customer to. */
|
|
147
|
+
get portalUrl() {
|
|
148
|
+
return this.resolution?.portal_url;
|
|
149
|
+
}
|
|
150
|
+
/** The exact command that settles this from a terminal. */
|
|
151
|
+
get cliCommand() {
|
|
152
|
+
return this.resolution?.cli_command;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* One line fit to show a person, whichever code arrived.
|
|
156
|
+
*
|
|
157
|
+
* Provided so every host product does not re-derive the same sentence, and get
|
|
158
|
+
* the commitment case wrong by telling the customer to add funds when waiting
|
|
159
|
+
* would also work.
|
|
160
|
+
*/
|
|
161
|
+
get summary() {
|
|
162
|
+
const short = this.shortfallUsd;
|
|
163
|
+
if (this.isCommitmentExceeded) {
|
|
164
|
+
const n = this.pendingIntents;
|
|
165
|
+
return `Pending work has already claimed this balance${n ? ` (${n} intent${n === 1 ? '' : 's'})` : ''}`
|
|
166
|
+
+ `${short ? `, leaving ${short} USD short` : ''}. Add funds, or wait for it to settle.`;
|
|
167
|
+
}
|
|
168
|
+
return short
|
|
169
|
+
? `Not enough funds: ${short} USD short of this request.`
|
|
170
|
+
: 'Not enough funds for this request.';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
61
173
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpB,MAAM,CAAS;IACf,IAAI,CAAS;IACb,SAAS,CAAU;IACnB,OAAO,CAAW;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpB,MAAM,CAAS;IACf,IAAI,CAAS;IACb,SAAS,CAAU;IACnB,OAAO,CAAW;IAClC;;;;;;;OAOG;IACa,IAAI,CAAW;IAE/B,YACE,OAAe,EACf,MAAc,EACd,IAAY,EACZ,OAAkE,EAAE;QAEpE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACxB,CAA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AAG,CAA4B,CAAC;QACvC,OAAO,OAAO,CAAC,CAAC,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAE,CAAuB,CAAC,CAAC,CAAC,IAAI,CAAC;IAChF,CAAC;IAED,yDAAyD;IACzD,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;IACrC,CAAC;IAED,2DAA2D;IAC3D,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACH,IAAI,OAAO;QACT,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC;QAChC,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC;YAC9B,OAAO,gDAAgD,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;kBACnG,GAAG,KAAK,CAAC,CAAC,CAAC,aAAa,KAAK,YAAY,CAAC,CAAC,CAAC,EAAE,wCAAwC,CAAC;QAC7F,CAAC;QACD,OAAO,KAAK;YACV,CAAC,CAAC,qBAAqB,KAAK,6BAA6B;YACzD,CAAC,CAAC,oCAAoC,CAAC;IAC3C,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { CertenClient, paginate, paginateWithTotal, DEFAULT_BASE_URL } from './client.js';
|
|
2
2
|
export * from './types.js';
|
|
3
3
|
export type { SignFn, ProofGatedCallParams, TransferParams, OpenedIntent } from './resources/execute.js';
|
|
4
|
-
export { CertenError, CertenAuthError, CertenRateLimitError, CertenBadRequestError, CertenServerError, } from './errors.js';
|
|
4
|
+
export { CertenError, CertenAuthError, CertenRateLimitError, CertenBadRequestError, CertenServerError, CertenPaymentRequiredError, } from './errors.js';
|
|
5
|
+
export type { PaymentResolution } from './errors.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAC3B,YAAY,EAAE,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { CertenClient, paginate, paginateWithTotal, DEFAULT_BASE_URL } from './client.js';
|
|
2
2
|
export * from './types.js';
|
|
3
|
-
export { CertenError, CertenAuthError, CertenRateLimitError, CertenBadRequestError, CertenServerError, } from './errors.js';
|
|
3
|
+
export { CertenError, CertenAuthError, CertenRateLimitError, CertenBadRequestError, CertenServerError, CertenPaymentRequiredError, } from './errors.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc,YAAY,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import type { BalanceResponse, ObligationsResponse, DepositTarget, DepositIntentStatus } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Balance, commitments, and adding funds.
|
|
5
|
+
*
|
|
6
|
+
* The two numbers here are easy to confuse and only one of them is safe to act
|
|
7
|
+
* on. `spendable_usd` is available balance plus any credit line. `remaining_usd`
|
|
8
|
+
* (from `obligations`) subtracts what pending intents will consume when they
|
|
9
|
+
* execute — and multi-signature intents can wait hours or weeks for quorum, so an
|
|
10
|
+
* account can hold a balance that is entirely committed and still be refused on
|
|
11
|
+
* its next call. Show or gate on `remaining_usd`.
|
|
12
|
+
*
|
|
13
|
+
* Funding has two attribution mechanisms and this resource exposes one of them.
|
|
14
|
+
* `openPayment` declares an exact amount to send, matched inside a TTL — it needs
|
|
15
|
+
* no registered wallet and suits a first deposit. Registering a payer address, so
|
|
16
|
+
* every future send credits automatically, is deliberately NOT here: that asserts
|
|
17
|
+
* deposits from an address belong to your organization, so it requires a signed-in
|
|
18
|
+
* owner or admin in the portal rather than a machine key.
|
|
19
|
+
*/
|
|
20
|
+
export declare class BillingResource {
|
|
21
|
+
private http;
|
|
22
|
+
constructor(http: AxiosInstance);
|
|
23
|
+
/** Available, held, credit line, and spendable. Requires `billing:read`. */
|
|
24
|
+
balance(): Promise<BalanceResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Pending intents and what they will cost — including `remaining_usd`, the
|
|
27
|
+
* amount that may actually be committed to new work.
|
|
28
|
+
*/
|
|
29
|
+
obligations(): Promise<ObligationsResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* Where to send stablecoin, optionally opening a single-use payment matched on
|
|
32
|
+
* the exact amount.
|
|
33
|
+
*
|
|
34
|
+
* Omit `amountUsd` to read the deposit address without opening anything — an
|
|
35
|
+
* intent for an unspecified amount could never be matched. Requires
|
|
36
|
+
* `billing:fund` (or `billing:write`).
|
|
37
|
+
*/
|
|
38
|
+
openPayment(params: {
|
|
39
|
+
chain: string;
|
|
40
|
+
amountUsd?: string;
|
|
41
|
+
}): Promise<DepositTarget>;
|
|
42
|
+
/**
|
|
43
|
+
* Status of a payment you opened. Requires `billing:read`.
|
|
44
|
+
*
|
|
45
|
+
* Use this rather than watching the balance: a second deposit or a charge in the
|
|
46
|
+
* same window moves the balance too, so inferring from it reports the wrong
|
|
47
|
+
* payment as matched.
|
|
48
|
+
*/
|
|
49
|
+
payment(reference: string): Promise<DepositIntentStatus>;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve once the payment is credited, or when it expires.
|
|
52
|
+
*
|
|
53
|
+
* Returns the terminal status rather than throwing on expiry — an expired
|
|
54
|
+
* payment is an ordinary outcome the caller should report, not an error. Only a
|
|
55
|
+
* genuine transport or auth failure throws.
|
|
56
|
+
*/
|
|
57
|
+
waitForPayment(reference: string, opts?: {
|
|
58
|
+
intervalMs?: number;
|
|
59
|
+
timeoutMs?: number;
|
|
60
|
+
onPoll?: (status: DepositIntentStatus) => void;
|
|
61
|
+
}): Promise<DepositIntentStatus>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEvC,4EAA4E;IACtE,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC;IAKzC;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAKjD;;;;;;;OAOG;IACG,WAAW,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAQxF;;;;;;OAMG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO9D;;;;;;OAMG;IACG,cAAc,CAClB,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE;QACJ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;KAC3C,GACL,OAAO,CAAC,mBAAmB,CAAC;CAchC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Balance, commitments, and adding funds.
|
|
3
|
+
*
|
|
4
|
+
* The two numbers here are easy to confuse and only one of them is safe to act
|
|
5
|
+
* on. `spendable_usd` is available balance plus any credit line. `remaining_usd`
|
|
6
|
+
* (from `obligations`) subtracts what pending intents will consume when they
|
|
7
|
+
* execute — and multi-signature intents can wait hours or weeks for quorum, so an
|
|
8
|
+
* account can hold a balance that is entirely committed and still be refused on
|
|
9
|
+
* its next call. Show or gate on `remaining_usd`.
|
|
10
|
+
*
|
|
11
|
+
* Funding has two attribution mechanisms and this resource exposes one of them.
|
|
12
|
+
* `openPayment` declares an exact amount to send, matched inside a TTL — it needs
|
|
13
|
+
* no registered wallet and suits a first deposit. Registering a payer address, so
|
|
14
|
+
* every future send credits automatically, is deliberately NOT here: that asserts
|
|
15
|
+
* deposits from an address belong to your organization, so it requires a signed-in
|
|
16
|
+
* owner or admin in the portal rather than a machine key.
|
|
17
|
+
*/
|
|
18
|
+
export class BillingResource {
|
|
19
|
+
http;
|
|
20
|
+
constructor(http) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
}
|
|
23
|
+
/** Available, held, credit line, and spendable. Requires `billing:read`. */
|
|
24
|
+
async balance() {
|
|
25
|
+
const { data } = await this.http.get('/v1/billing/balance');
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Pending intents and what they will cost — including `remaining_usd`, the
|
|
30
|
+
* amount that may actually be committed to new work.
|
|
31
|
+
*/
|
|
32
|
+
async obligations() {
|
|
33
|
+
const { data } = await this.http.get('/v1/billing/obligations');
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Where to send stablecoin, optionally opening a single-use payment matched on
|
|
38
|
+
* the exact amount.
|
|
39
|
+
*
|
|
40
|
+
* Omit `amountUsd` to read the deposit address without opening anything — an
|
|
41
|
+
* intent for an unspecified amount could never be matched. Requires
|
|
42
|
+
* `billing:fund` (or `billing:write`).
|
|
43
|
+
*/
|
|
44
|
+
async openPayment(params) {
|
|
45
|
+
const { data } = await this.http.post('/v1/billing/deposits', {
|
|
46
|
+
chain: params.chain,
|
|
47
|
+
...(params.amountUsd ? { amount_usd: params.amountUsd } : {}),
|
|
48
|
+
});
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Status of a payment you opened. Requires `billing:read`.
|
|
53
|
+
*
|
|
54
|
+
* Use this rather than watching the balance: a second deposit or a charge in the
|
|
55
|
+
* same window moves the balance too, so inferring from it reports the wrong
|
|
56
|
+
* payment as matched.
|
|
57
|
+
*/
|
|
58
|
+
async payment(reference) {
|
|
59
|
+
const { data } = await this.http.get(`/v1/billing/deposits/${encodeURIComponent(reference)}`);
|
|
60
|
+
return data.intent;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Resolve once the payment is credited, or when it expires.
|
|
64
|
+
*
|
|
65
|
+
* Returns the terminal status rather than throwing on expiry — an expired
|
|
66
|
+
* payment is an ordinary outcome the caller should report, not an error. Only a
|
|
67
|
+
* genuine transport or auth failure throws.
|
|
68
|
+
*/
|
|
69
|
+
async waitForPayment(reference, opts = {}) {
|
|
70
|
+
const intervalMs = opts.intervalMs ?? 5_000;
|
|
71
|
+
const timeoutMs = opts.timeoutMs ?? 60 * 60 * 1_000;
|
|
72
|
+
const deadline = Date.now() + timeoutMs;
|
|
73
|
+
for (;;) {
|
|
74
|
+
const status = await this.payment(reference);
|
|
75
|
+
opts.onPoll?.(status);
|
|
76
|
+
if (status.status !== 'open')
|
|
77
|
+
return status;
|
|
78
|
+
if (new Date(status.expires_at).getTime() <= Date.now())
|
|
79
|
+
return status;
|
|
80
|
+
if (Date.now() >= deadline)
|
|
81
|
+
return status;
|
|
82
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/resources/billing.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,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,CAAC;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAExC,SAAS,CAAC;YACR,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC7C,IAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;YACtB,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM;gBAAE,OAAO,MAAM,CAAC;YAC5C,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE;gBAAE,OAAO,MAAM,CAAC;YACvE,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ;gBAAE,OAAO,MAAM,CAAC;YAC1C,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
|
-
import type { ContractCall, TransactionResponse } from '../types.js';
|
|
2
|
+
import type { ContractAddresses, ContractCall, ProofClass, TransactionResponse } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* The proof-gated execution flow, as one call instead of four.
|
|
5
5
|
*
|
|
@@ -27,16 +27,39 @@ export interface ProofGatedCallParams {
|
|
|
27
27
|
chain: string;
|
|
28
28
|
chainId?: number;
|
|
29
29
|
contractCall: ContractCall;
|
|
30
|
+
/**
|
|
31
|
+
* Override the CERTEN deployment addresses (anchor, abstractAccount, …). Omit unless you are
|
|
32
|
+
* pointing at a non-standard deployment — the gateway applies the correct defaults.
|
|
33
|
+
*/
|
|
34
|
+
contractAddresses?: ContractAddresses;
|
|
30
35
|
sign: SignFn;
|
|
31
36
|
publicKey: string;
|
|
32
37
|
/** Nominate a seat on the page. Defaults to `publicKey`. */
|
|
33
38
|
signerPublicKey?: string;
|
|
34
39
|
/** Nominate which page of the book signs, e.g. `acc://panel.acme/book/2`. */
|
|
35
40
|
signerKeyPage?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Schedule the proof cycle: `on_demand` (default, ~60–110s) or `on_cadence` (batched, cheaper,
|
|
43
|
+
* slower). It changes when the proof is produced, never what it proves.
|
|
44
|
+
*/
|
|
45
|
+
proofClass?: ProofClass;
|
|
36
46
|
idempotencyKey?: string;
|
|
37
47
|
}
|
|
38
48
|
export interface TransferParams {
|
|
39
49
|
identityId: string;
|
|
50
|
+
/**
|
|
51
|
+
* The signing identity's ADI, e.g. `acc://your-org.acme`.
|
|
52
|
+
*
|
|
53
|
+
* REQUIRED. Its absence is why this method never worked: the upstream native-transfer path reads
|
|
54
|
+
* `intent.adiUrl` with no null check, so an intent without one threw upstream and came back as a
|
|
55
|
+
* bodyless `502` — which reads as "the gateway is down", not "you omitted a field". See
|
|
56
|
+
* certenIO/accumulate-api-bridge#1.
|
|
57
|
+
*
|
|
58
|
+
* Requiring it is not a breaking change in practice: every call that omitted it failed, so there
|
|
59
|
+
* is no working code to break. It is the only one of the four fields that path needs which the
|
|
60
|
+
* caller must supply — `id`, `initiatedBy` and `timestamp` are generated below.
|
|
61
|
+
*/
|
|
62
|
+
adiUrl: string;
|
|
40
63
|
fromChain: string;
|
|
41
64
|
toChain: string;
|
|
42
65
|
fromAddress: string;
|
|
@@ -48,6 +71,11 @@ export interface TransferParams {
|
|
|
48
71
|
publicKey: string;
|
|
49
72
|
signerPublicKey?: string;
|
|
50
73
|
signerKeyPage?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Schedule the proof cycle: `on_demand` (default, ~60–110s) or `on_cadence` (batched, cheaper,
|
|
76
|
+
* slower). It changes when the proof is produced, never what it proves.
|
|
77
|
+
*/
|
|
78
|
+
proofClass?: ProofClass;
|
|
51
79
|
idempotencyKey?: string;
|
|
52
80
|
}
|
|
53
81
|
export interface OpenedIntent {
|
|
@@ -101,7 +129,9 @@ export declare class ExecuteResource {
|
|
|
101
129
|
* normal case for a governance or authorization transaction, and the case where a naive lookup returns
|
|
102
130
|
* empty and looks like a bug.
|
|
103
131
|
*/
|
|
104
|
-
proof(intentId: string
|
|
132
|
+
proof(intentId: string, { timeoutMs }?: {
|
|
133
|
+
timeoutMs?: number;
|
|
134
|
+
}): Promise<{
|
|
105
135
|
kind: 'certen-proof';
|
|
106
136
|
proofId: string;
|
|
107
137
|
proof: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/resources/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/resources/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAqB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvH;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,MAAM;IACrB,2GAA2G;IAC3G,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB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AAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;KACzC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAqBpC;;;;;OAKG;IACG,IAAI,CACR,QAAQ,EAAE,MAAM,EAChB,EAAE,SAAmB,EAAE,UAAkB,EAAE,MAAM,EAAE,GAAE;QACnD,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,mBAAmB,KAAK,IAAI,CAAC;KACvC,GACL,OAAO,CAAC,mBAAmB,CAAC;IAoB/B;;;;;;OAMG;IACG,KAAK,CACT,QAAQ,EAAE,MAAM,EAChB,EAAE,SAA4B,EAAE,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GAC5D,OAAO,CACN;QAAE,IAAI,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,mBAAmB,CAAA;KAAE,GACtF;QAAE,IAAI,EAAE,oBAAoB,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,mBAAmB,CAAA;KAAE,CAChG;YAiBa,IAAI;CAmCnB"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
1
2
|
import { omitUndefined } from '../internal.js';
|
|
2
3
|
/** Terminal states. `wait()` stops on these rather than polling forever. */
|
|
3
4
|
const DONE = ['completed', 'delivered', 'proven'];
|
|
4
5
|
const FAILED = ['failed', 'error'];
|
|
6
|
+
/**
|
|
7
|
+
* Proof fetches get a longer budget than the client's 30s default.
|
|
8
|
+
*
|
|
9
|
+
* Measured against the live gateway: fetching the Accumulate merkle receipt exceeded 30s and failed
|
|
10
|
+
* as `NETWORK_ERROR`. Retrieving evidence for an already-completed transaction is exactly the call
|
|
11
|
+
* that should wait rather than fail — nothing is pending on it, and the alternative is telling a
|
|
12
|
+
* caller their proof does not exist when it does. Override per call with `proof(id, { timeoutMs })`.
|
|
13
|
+
*/
|
|
14
|
+
const PROOF_TIMEOUT_MS = 120_000;
|
|
5
15
|
export class ExecuteResource {
|
|
6
16
|
http;
|
|
7
17
|
newIdempotencyKey;
|
|
@@ -33,8 +43,15 @@ export class ExecuteResource {
|
|
|
33
43
|
return this.open({
|
|
34
44
|
identity_id: p.identityId,
|
|
35
45
|
intent,
|
|
36
|
-
contract_addresses
|
|
46
|
+
// NOT the call target. `contract_addresses` names the CERTEN deployment (anchor, anchorV2,
|
|
47
|
+
// abstractAccount, entryPoint, factory) and must be an OBJECT — this sent `[target]`, which
|
|
48
|
+
// the endpoint rejects with `/contract_addresses must be object`, so every contractCall
|
|
49
|
+
// failed with a 400 naming a field the caller never set. The gateway applies the right
|
|
50
|
+
// defaults when it is omitted, so omitting it is correct; `contractAddresses` overrides it
|
|
51
|
+
// only for a non-standard deployment.
|
|
52
|
+
contract_addresses: p.contractAddresses,
|
|
37
53
|
signer_public_key: p.signerPublicKey ?? p.publicKey,
|
|
54
|
+
proof_class: p.proofClass,
|
|
38
55
|
signer_key_page: p.signerKeyPage,
|
|
39
56
|
}, p.sign, p.signerPublicKey ?? p.publicKey, p.idempotencyKey);
|
|
40
57
|
}
|
|
@@ -43,6 +60,19 @@ export class ExecuteResource {
|
|
|
43
60
|
return this.open({
|
|
44
61
|
identity_id: p.identityId,
|
|
45
62
|
intent: {
|
|
63
|
+
// The upstream native-transfer path requires adiUrl, id, initiatedBy AND timestamp, none of
|
|
64
|
+
// which appear in the transfer shape the API documents. Omitting any one of them produces a
|
|
65
|
+
// bodyless 502 rather than a validation error: `adiUrl` is dereferenced with no null check,
|
|
66
|
+
// and `new Date(intent.timestamp).toISOString()` throws RangeError on undefined. Verified
|
|
67
|
+
// field by field against the live gateway — see certenIO/accumulate-api-bridge#1.
|
|
68
|
+
//
|
|
69
|
+
// The multi-leg branch upstream already defaults id/initiatedBy/timestamp itself; this path
|
|
70
|
+
// does not, so the SDK supplies them. Once the upstream defaults them too, these become
|
|
71
|
+
// harmless no-ops rather than load-bearing.
|
|
72
|
+
adiUrl: p.adiUrl,
|
|
73
|
+
id: randomUUID(),
|
|
74
|
+
initiatedBy: p.adiUrl,
|
|
75
|
+
timestamp: Date.now(),
|
|
46
76
|
fromChain: p.fromChain,
|
|
47
77
|
toChain: p.toChain,
|
|
48
78
|
fromAddress: p.fromAddress,
|
|
@@ -51,6 +81,7 @@ export class ExecuteResource {
|
|
|
51
81
|
tokenSymbol: p.tokenSymbol,
|
|
52
82
|
},
|
|
53
83
|
signer_public_key: p.signerPublicKey ?? p.publicKey,
|
|
84
|
+
proof_class: p.proofClass,
|
|
54
85
|
signer_key_page: p.signerKeyPage,
|
|
55
86
|
}, p.sign, p.signerPublicKey ?? p.publicKey, p.idempotencyKey);
|
|
56
87
|
}
|
|
@@ -113,18 +144,18 @@ export class ExecuteResource {
|
|
|
113
144
|
* normal case for a governance or authorization transaction, and the case where a naive lookup returns
|
|
114
145
|
* empty and looks like a bug.
|
|
115
146
|
*/
|
|
116
|
-
async proof(intentId) {
|
|
147
|
+
async proof(intentId, { timeoutMs = PROOF_TIMEOUT_MS } = {}) {
|
|
117
148
|
const { data: intent } = await this.http.get(`/v1/transaction/${intentId}`);
|
|
118
149
|
const proofId = intent.proof_id;
|
|
119
150
|
if (proofId) {
|
|
120
|
-
const { data: proof } = await this.http.get(`/v1/proof/${proofId}
|
|
151
|
+
const { data: proof } = await this.http.get(`/v1/proof/${proofId}`, { timeout: timeoutMs });
|
|
121
152
|
return { kind: 'certen-proof', proofId, proof, intent };
|
|
122
153
|
}
|
|
123
154
|
const hash = String(intent.accum_tx_hash ?? '').match(/([a-f0-9]{64})/)?.[1];
|
|
124
155
|
if (!hash) {
|
|
125
156
|
throw new Error(`certen: intent ${intentId} has neither a proof_id nor an Accumulate transaction hash`);
|
|
126
157
|
}
|
|
127
|
-
const { data: receipt } = await this.http.get(`/v1/proof/tx/${hash}/receipt
|
|
158
|
+
const { data: receipt } = await this.http.get(`/v1/proof/tx/${hash}/receipt`, { timeout: timeoutMs });
|
|
128
159
|
return { kind: 'accumulate-receipt', txHash: hash, receipt, intent };
|
|
129
160
|
}
|
|
130
161
|
// ── shared open-and-sign ──────────────────────────────────────────────────────────────────────────
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/resources/execute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/resources/execute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA2F/C,4EAA4E;AAC5E,MAAM,IAAI,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;AAClD,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEjC,MAAM,OAAO,eAAe;IAEhB;IACA;IAFV,YACU,IAAmB,EACnB,iBAA+B;QAD/B,SAAI,GAAJ,IAAI,CAAe;QACnB,sBAAiB,GAAjB,iBAAiB,CAAc;IACtC,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,CAAuB;QACxC,MAAM,MAAM,GAAsB;YAChC,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,IAAI,EAAE,CAAC;oBACL,KAAK,EAAE,OAAO;oBACd,KAAK,EAAE,CAAC,CAAC,KAAK;oBACd,OAAO,EAAE,CAAC,CA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