@4mica/sdk 1.2.16 → 1.3.1
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/README.md +59 -25
- package/dist/index.cjs +5513 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2730 -0
- package/dist/{src/abi/core4mica.d.ts → index.d.ts} +1032 -1
- package/dist/index.js +5439 -0
- package/dist/index.js.map +1 -0
- package/dist/models-B15ouNYG.d.cts +386 -0
- package/dist/models-B15ouNYG.d.ts +386 -0
- package/dist/server.cjs +172 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +119 -0
- package/dist/server.d.ts +119 -0
- package/dist/server.js +165 -0
- package/dist/server.js.map +1 -0
- package/package.json +52 -43
- package/dist/package.json +0 -80
- package/dist/src/abi/core4mica.js +0 -2200
- package/dist/src/abi/erc20.d.ts +0 -151
- package/dist/src/abi/erc20.js +0 -201
- package/dist/src/auth.d.ts +0 -62
- package/dist/src/auth.js +0 -218
- package/dist/src/bls.d.ts +0 -6
- package/dist/src/bls.js +0 -247
- package/dist/src/chain.d.ts +0 -2
- package/dist/src/chain.js +0 -26
- package/dist/src/client/index.d.ts +0 -71
- package/dist/src/client/index.js +0 -120
- package/dist/src/client/recipient.d.ts +0 -129
- package/dist/src/client/recipient.js +0 -257
- package/dist/src/client/shared.d.ts +0 -11
- package/dist/src/client/shared.js +0 -17
- package/dist/src/client/user.d.ts +0 -109
- package/dist/src/client/user.js +0 -147
- package/dist/src/config.d.ts +0 -103
- package/dist/src/config.js +0 -197
- package/dist/src/constants.d.ts +0 -4
- package/dist/src/constants.js +0 -7
- package/dist/src/contract.d.ts +0 -55
- package/dist/src/contract.js +0 -312
- package/dist/src/debug.d.ts +0 -2
- package/dist/src/debug.js +0 -5
- package/dist/src/errors.d.ts +0 -58
- package/dist/src/errors.js +0 -81
- package/dist/src/guarantee.d.ts +0 -25
- package/dist/src/guarantee.js +0 -272
- package/dist/src/http.d.ts +0 -11
- package/dist/src/http.js +0 -57
- package/dist/src/index.d.ts +0 -17
- package/dist/src/index.js +0 -33
- package/dist/src/models.d.ts +0 -259
- package/dist/src/models.js +0 -356
- package/dist/src/networks.d.ts +0 -40
- package/dist/src/networks.js +0 -57
- package/dist/src/payment.d.ts +0 -82
- package/dist/src/payment.js +0 -67
- package/dist/src/rpc.d.ts +0 -38
- package/dist/src/rpc.js +0 -161
- package/dist/src/serde.d.ts +0 -5
- package/dist/src/serde.js +0 -33
- package/dist/src/signing.d.ts +0 -170
- package/dist/src/signing.js +0 -311
- package/dist/src/utils.d.ts +0 -11
- package/dist/src/utils.js +0 -90
- package/dist/src/validation.d.ts +0 -32
- package/dist/src/validation.js +0 -84
- package/dist/src/wallet/cdp.d.ts +0 -13
- package/dist/src/wallet/cdp.js +0 -78
- package/dist/src/wallet/index.d.ts +0 -2
- package/dist/src/wallet/index.js +0 -5
- package/dist/src/x402/index.d.ts +0 -90
- package/dist/src/x402/index.js +0 -243
- package/dist/src/x402/models.d.ts +0 -75
- package/dist/src/x402/models.js +0 -2
package/dist/src/networks.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NETWORKS = void 0;
|
|
4
|
-
exports.resolveNetworkRpcUrl = resolveNetworkRpcUrl;
|
|
5
|
-
exports.resolvePublicRpcUrl = resolvePublicRpcUrl;
|
|
6
|
-
/**
|
|
7
|
-
* Hosted 4Mica network deployments, keyed by human-readable shorthand.
|
|
8
|
-
*
|
|
9
|
-
* Pass the shorthand (or the CAIP-2 string) to {@link ConfigBuilder.network}
|
|
10
|
-
* to select a network without writing a URL.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { Client, ConfigBuilder, NETWORKS } from "@4mica/sdk";
|
|
15
|
-
*
|
|
16
|
-
* // By shorthand
|
|
17
|
-
* const cfg = new ConfigBuilder()
|
|
18
|
-
* .network("base")
|
|
19
|
-
* .walletPrivateKey("0x...")
|
|
20
|
-
* .build();
|
|
21
|
-
*
|
|
22
|
-
* // Inspect available networks
|
|
23
|
-
* console.log(NETWORKS["base"].caip2); // "eip155:8453"
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
exports.NETWORKS = {
|
|
27
|
-
base: {
|
|
28
|
-
caip2: 'eip155:8453',
|
|
29
|
-
rpcUrl: 'https://base.api.4mica.xyz/',
|
|
30
|
-
publicRpcUrl: 'https://base-rpc.publicnode.com',
|
|
31
|
-
},
|
|
32
|
-
'base-sepolia': {
|
|
33
|
-
caip2: 'eip155:84532',
|
|
34
|
-
rpcUrl: 'https://base.sepolia.api.4mica.xyz/',
|
|
35
|
-
publicRpcUrl: 'https://base-sepolia-rpc.publicnode.com',
|
|
36
|
-
},
|
|
37
|
-
'ethereum-sepolia': {
|
|
38
|
-
caip2: 'eip155:11155111',
|
|
39
|
-
rpcUrl: 'https://ethereum.sepolia.api.4mica.xyz/',
|
|
40
|
-
publicRpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
const NETWORKS_BY_CAIP2 = Object.fromEntries(Object.values(exports.NETWORKS).map((n) => [n.caip2, n]));
|
|
44
|
-
/**
|
|
45
|
-
* Resolve a network shorthand or CAIP-2 identifier to a core API URL.
|
|
46
|
-
* Returns `undefined` if the identifier is not a known hosted network.
|
|
47
|
-
*/
|
|
48
|
-
function resolveNetworkRpcUrl(network) {
|
|
49
|
-
return exports.NETWORKS[network]?.rpcUrl ?? NETWORKS_BY_CAIP2[network]?.rpcUrl;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Resolve a CAIP-2 identifier to a reliable public Ethereum RPC URL.
|
|
53
|
-
* Returns `undefined` for unknown networks.
|
|
54
|
-
*/
|
|
55
|
-
function resolvePublicRpcUrl(caip2) {
|
|
56
|
-
return NETWORKS_BY_CAIP2[caip2]?.publicRpcUrl;
|
|
57
|
-
}
|
package/dist/src/payment.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { PaymentGuaranteeRequestClaims, PaymentGuaranteeRequestClaimsV2, PaymentSignature, SigningScheme } from './models';
|
|
2
|
-
interface PaymentPayloadClaimsBase {
|
|
3
|
-
user_address: string;
|
|
4
|
-
recipient_address: string;
|
|
5
|
-
tab_id: string;
|
|
6
|
-
req_id: string;
|
|
7
|
-
amount: string;
|
|
8
|
-
timestamp: number;
|
|
9
|
-
asset_address: string;
|
|
10
|
-
}
|
|
11
|
-
/** Wire-format representation of V1 payment guarantee claims sent to the core RPC. */
|
|
12
|
-
export interface PaymentPayloadClaims extends PaymentPayloadClaimsBase {
|
|
13
|
-
version: 'v1';
|
|
14
|
-
}
|
|
15
|
-
/** Wire-format representation of V2 payment guarantee claims sent to the core RPC. */
|
|
16
|
-
export interface PaymentPayloadClaimsV2 extends PaymentPayloadClaimsBase {
|
|
17
|
-
version: 'v2';
|
|
18
|
-
validation_registry_address: string;
|
|
19
|
-
validation_request_hash: string;
|
|
20
|
-
validation_chain_id: number;
|
|
21
|
-
validator_address: string;
|
|
22
|
-
validator_agent_id: string;
|
|
23
|
-
min_validation_score: number;
|
|
24
|
-
validation_subject_hash: string;
|
|
25
|
-
job_hash: string;
|
|
26
|
-
required_validation_tag: string;
|
|
27
|
-
}
|
|
28
|
-
/** Assembled payment payload ready to be submitted to the core RPC `issueGuarantee` endpoint. */
|
|
29
|
-
export interface PaymentPayload {
|
|
30
|
-
claims: PaymentPayloadClaims | PaymentPayloadClaimsV2;
|
|
31
|
-
/** 65-byte ECDSA signature as a `0x`-prefixed hex string. */
|
|
32
|
-
signature: string;
|
|
33
|
-
scheme: SigningScheme;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Serialize V1 payment claims to the wire format expected by the core RPC.
|
|
37
|
-
*
|
|
38
|
-
* @param claims - V1 payment guarantee request claims.
|
|
39
|
-
* @returns JSON-serialisable object with snake_case keys and hex-encoded `uint256` fields.
|
|
40
|
-
*/
|
|
41
|
-
export declare function serializePaymentClaims(claims: PaymentGuaranteeRequestClaims): PaymentPayloadClaims;
|
|
42
|
-
/**
|
|
43
|
-
* Serialize V2 payment claims to the wire format expected by the core RPC.
|
|
44
|
-
*
|
|
45
|
-
* Extends the V1 serialisation with the nine additional validation policy fields.
|
|
46
|
-
*
|
|
47
|
-
* @param claims - V2 payment guarantee request claims with validation policy.
|
|
48
|
-
* @returns JSON-serialisable object with snake_case keys and hex-encoded `uint256` fields.
|
|
49
|
-
*/
|
|
50
|
-
export declare function serializePaymentClaimsV2(claims: PaymentGuaranteeRequestClaimsV2): PaymentPayloadClaimsV2;
|
|
51
|
-
/**
|
|
52
|
-
* Build a {@link PaymentPayload} from V2 claims and a {@link PaymentSignature}.
|
|
53
|
-
*
|
|
54
|
-
* @param claims - V2 payment guarantee request claims.
|
|
55
|
-
* @param signature - Pre-built signature object (includes the scheme).
|
|
56
|
-
*/
|
|
57
|
-
export declare function buildPaymentPayload(claims: PaymentGuaranteeRequestClaimsV2, signature: PaymentSignature): PaymentPayload;
|
|
58
|
-
/**
|
|
59
|
-
* Build a {@link PaymentPayload} from V2 claims, a raw signature hex string, and a scheme.
|
|
60
|
-
*
|
|
61
|
-
* @param claims - V2 payment guarantee request claims.
|
|
62
|
-
* @param signature - 65-byte ECDSA signature as a `0x`-prefixed hex string.
|
|
63
|
-
* @param scheme - Signing scheme used to produce the signature.
|
|
64
|
-
*/
|
|
65
|
-
export declare function buildPaymentPayload(claims: PaymentGuaranteeRequestClaimsV2, signature: string, scheme: SigningScheme): PaymentPayload;
|
|
66
|
-
/**
|
|
67
|
-
* Build a {@link PaymentPayload} from V1 claims and a {@link PaymentSignature}.
|
|
68
|
-
*
|
|
69
|
-
* @param claims - V1 payment guarantee request claims.
|
|
70
|
-
* @param signature - Pre-built signature object (includes the scheme).
|
|
71
|
-
*/
|
|
72
|
-
export declare function buildPaymentPayload(claims: PaymentGuaranteeRequestClaims, signature: PaymentSignature): PaymentPayload;
|
|
73
|
-
/**
|
|
74
|
-
* Build a {@link PaymentPayload} from V1 claims, a raw signature hex string, and a scheme.
|
|
75
|
-
*
|
|
76
|
-
* @param claims - V1 payment guarantee request claims.
|
|
77
|
-
* @param signature - 65-byte ECDSA signature as a `0x`-prefixed hex string.
|
|
78
|
-
* @param scheme - Signing scheme used to produce the signature.
|
|
79
|
-
* @throws {@link SigningError} if `signature` is a string but no `scheme` is provided.
|
|
80
|
-
*/
|
|
81
|
-
export declare function buildPaymentPayload(claims: PaymentGuaranteeRequestClaims, signature: string, scheme: SigningScheme): PaymentPayload;
|
|
82
|
-
export {};
|
package/dist/src/payment.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializePaymentClaims = serializePaymentClaims;
|
|
4
|
-
exports.serializePaymentClaimsV2 = serializePaymentClaimsV2;
|
|
5
|
-
exports.buildPaymentPayload = buildPaymentPayload;
|
|
6
|
-
const models_1 = require("./models");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
const errors_1 = require("./errors");
|
|
9
|
-
/**
|
|
10
|
-
* Serialize V1 payment claims to the wire format expected by the core RPC.
|
|
11
|
-
*
|
|
12
|
-
* @param claims - V1 payment guarantee request claims.
|
|
13
|
-
* @returns JSON-serialisable object with snake_case keys and hex-encoded `uint256` fields.
|
|
14
|
-
*/
|
|
15
|
-
function serializePaymentClaims(claims) {
|
|
16
|
-
return {
|
|
17
|
-
version: 'v1',
|
|
18
|
-
user_address: claims.userAddress.toLowerCase(),
|
|
19
|
-
recipient_address: claims.recipientAddress.toLowerCase(),
|
|
20
|
-
tab_id: (0, utils_1.serializeU256)(claims.tabId),
|
|
21
|
-
req_id: (0, utils_1.serializeU256)(claims.reqId),
|
|
22
|
-
amount: (0, utils_1.serializeU256)(claims.amount),
|
|
23
|
-
asset_address: claims.assetAddress.toLowerCase(),
|
|
24
|
-
timestamp: claims.timestamp,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Serialize V2 payment claims to the wire format expected by the core RPC.
|
|
29
|
-
*
|
|
30
|
-
* Extends the V1 serialisation with the nine additional validation policy fields.
|
|
31
|
-
*
|
|
32
|
-
* @param claims - V2 payment guarantee request claims with validation policy.
|
|
33
|
-
* @returns JSON-serialisable object with snake_case keys and hex-encoded `uint256` fields.
|
|
34
|
-
*/
|
|
35
|
-
function serializePaymentClaimsV2(claims) {
|
|
36
|
-
return {
|
|
37
|
-
...serializePaymentClaims(claims),
|
|
38
|
-
version: 'v2',
|
|
39
|
-
validation_registry_address: claims.validationRegistryAddress.toLowerCase(),
|
|
40
|
-
validation_request_hash: claims.validationRequestHash.toLowerCase(),
|
|
41
|
-
validation_chain_id: claims.validationChainId,
|
|
42
|
-
validator_address: claims.validatorAddress.toLowerCase(),
|
|
43
|
-
validator_agent_id: (0, utils_1.serializeU256)(claims.validatorAgentId),
|
|
44
|
-
min_validation_score: claims.minValidationScore,
|
|
45
|
-
validation_subject_hash: claims.validationSubjectHash.toLowerCase(),
|
|
46
|
-
job_hash: claims.jobHash.toLowerCase(),
|
|
47
|
-
required_validation_tag: claims.requiredValidationTag,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function buildPaymentPayload(claims, signature, scheme) {
|
|
51
|
-
const signed = typeof signature === 'string'
|
|
52
|
-
? (() => {
|
|
53
|
-
if (!scheme) {
|
|
54
|
-
throw new errors_1.SigningError('scheme is required when providing a signature string');
|
|
55
|
-
}
|
|
56
|
-
return { signature, scheme };
|
|
57
|
-
})()
|
|
58
|
-
: signature;
|
|
59
|
-
const serialized = claims instanceof models_1.PaymentGuaranteeRequestClaimsV2
|
|
60
|
-
? serializePaymentClaimsV2(claims)
|
|
61
|
-
: serializePaymentClaims(claims);
|
|
62
|
-
return {
|
|
63
|
-
claims: serialized,
|
|
64
|
-
signature: signed.signature,
|
|
65
|
-
scheme: signed.scheme,
|
|
66
|
-
};
|
|
67
|
-
}
|
package/dist/src/rpc.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { AdminApiKeyInfo, AdminApiKeySecret, CorePublicParameters, SupportedTokensResponse, UserSuspensionStatus } from './models';
|
|
2
|
-
import { type FetchFn as HttpFetchFn } from './http';
|
|
3
|
-
export type FetchFn = HttpFetchFn;
|
|
4
|
-
export type BearerTokenProvider = () => string | Promise<string>;
|
|
5
|
-
export declare class RpcProxy {
|
|
6
|
-
private baseUrl;
|
|
7
|
-
private adminApiKey?;
|
|
8
|
-
private bearerToken?;
|
|
9
|
-
private bearerTokenProvider?;
|
|
10
|
-
private fetchFn;
|
|
11
|
-
constructor(endpoint: string, adminApiKey?: string, fetchFn?: FetchFn);
|
|
12
|
-
aclose(): Promise<void>;
|
|
13
|
-
withBearerToken(token: string): RpcProxy;
|
|
14
|
-
withTokenProvider(provider: BearerTokenProvider): RpcProxy;
|
|
15
|
-
private headers;
|
|
16
|
-
private resolveBearerToken;
|
|
17
|
-
private get;
|
|
18
|
-
private post;
|
|
19
|
-
getPublicParams(): Promise<CorePublicParameters>;
|
|
20
|
-
getSupportedTokens(): Promise<SupportedTokensResponse>;
|
|
21
|
-
issueGuarantee(body: unknown): Promise<Record<string, unknown>>;
|
|
22
|
-
createPaymentTab(body: unknown): Promise<Record<string, unknown>>;
|
|
23
|
-
listSettledTabs(recipientAddress: string): Promise<Record<string, unknown>[]>;
|
|
24
|
-
listPendingRemunerations(recipientAddress: string): Promise<Record<string, unknown>[]>;
|
|
25
|
-
getTab(tabId: number | bigint): Promise<Record<string, unknown> | null>;
|
|
26
|
-
listRecipientTabs(recipientAddress: string, settlementStatuses?: string[]): Promise<Record<string, unknown>[]>;
|
|
27
|
-
listUserTabs(userAddress: string, settlementStatuses?: string[]): Promise<Record<string, unknown>[]>;
|
|
28
|
-
getTabGuarantees(tabId: number | bigint): Promise<Record<string, unknown>[]>;
|
|
29
|
-
getLatestGuarantee(tabId: number | bigint): Promise<Record<string, unknown> | null>;
|
|
30
|
-
getGuarantee(tabId: number | bigint, reqId: number | bigint): Promise<Record<string, unknown> | null>;
|
|
31
|
-
listRecipientPayments(recipientAddress: string): Promise<Record<string, unknown>[]>;
|
|
32
|
-
getCollateralEventsForTab(tabId: number | bigint): Promise<Record<string, unknown>[]>;
|
|
33
|
-
getUserAssetBalance(userAddress: string, assetAddress: string): Promise<Record<string, unknown> | null>;
|
|
34
|
-
updateUserSuspension(userAddress: string, suspended: boolean): Promise<UserSuspensionStatus>;
|
|
35
|
-
createAdminApiKey(body: unknown): Promise<AdminApiKeySecret>;
|
|
36
|
-
listAdminApiKeys(): Promise<AdminApiKeyInfo[]>;
|
|
37
|
-
revokeAdminApiKey(keyId: string): Promise<AdminApiKeyInfo>;
|
|
38
|
-
}
|
package/dist/src/rpc.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RpcProxy = void 0;
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
|
-
const models_1 = require("./models");
|
|
6
|
-
const errors_1 = require("./errors");
|
|
7
|
-
const http_1 = require("./http");
|
|
8
|
-
const package_json_1 = require("../package.json");
|
|
9
|
-
const SDK_CLIENT_HEADER_VALUE = `ts-sdk-4mica/${package_json_1.version}`;
|
|
10
|
-
function serializeTabId(tabId) {
|
|
11
|
-
return `0x${BigInt(tabId).toString(16)}`;
|
|
12
|
-
}
|
|
13
|
-
class RpcProxy {
|
|
14
|
-
baseUrl;
|
|
15
|
-
adminApiKey;
|
|
16
|
-
bearerToken;
|
|
17
|
-
bearerTokenProvider;
|
|
18
|
-
fetchFn;
|
|
19
|
-
constructor(endpoint, adminApiKey, fetchFn = fetch) {
|
|
20
|
-
this.baseUrl = (0, http_1.normalizeBaseUrl)(endpoint);
|
|
21
|
-
this.adminApiKey = adminApiKey;
|
|
22
|
-
this.fetchFn = fetchFn;
|
|
23
|
-
}
|
|
24
|
-
async aclose() {
|
|
25
|
-
// no-op for symmetry with Python SDK
|
|
26
|
-
}
|
|
27
|
-
withBearerToken(token) {
|
|
28
|
-
this.bearerToken = token;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
withTokenProvider(provider) {
|
|
32
|
-
this.bearerTokenProvider = provider;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
async headers() {
|
|
36
|
-
const headers = { 'x-4mica-sdk': SDK_CLIENT_HEADER_VALUE };
|
|
37
|
-
if (this.adminApiKey) {
|
|
38
|
-
headers[constants_1.ADMIN_API_KEY_HEADER] = this.adminApiKey;
|
|
39
|
-
}
|
|
40
|
-
const token = await this.resolveBearerToken();
|
|
41
|
-
if (token) {
|
|
42
|
-
headers['Authorization'] = token;
|
|
43
|
-
}
|
|
44
|
-
return headers;
|
|
45
|
-
}
|
|
46
|
-
async resolveBearerToken() {
|
|
47
|
-
let token = this.bearerToken;
|
|
48
|
-
if (!token && this.bearerTokenProvider) {
|
|
49
|
-
token = await this.bearerTokenProvider();
|
|
50
|
-
}
|
|
51
|
-
if (!token) {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
const trimmed = token.trim();
|
|
55
|
-
if (/^bearer\s+/i.test(trimmed)) {
|
|
56
|
-
return trimmed;
|
|
57
|
-
}
|
|
58
|
-
return `Bearer ${trimmed}`;
|
|
59
|
-
}
|
|
60
|
-
async get(path) {
|
|
61
|
-
return (0, http_1.requestJson)(this.fetchFn, `${this.baseUrl}${path}`, {
|
|
62
|
-
headers: await this.headers(),
|
|
63
|
-
method: 'GET',
|
|
64
|
-
}, {
|
|
65
|
-
decodeError: (message) => new errors_1.RpcError(message),
|
|
66
|
-
httpError: (message, response, body) => new errors_1.RpcError(message, {
|
|
67
|
-
status: response.status,
|
|
68
|
-
body,
|
|
69
|
-
}),
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
async post(path, body) {
|
|
73
|
-
return (0, http_1.requestJson)(this.fetchFn, `${this.baseUrl}${path}`, {
|
|
74
|
-
headers: { 'content-type': 'application/json', ...(await this.headers()) },
|
|
75
|
-
method: 'POST',
|
|
76
|
-
body: JSON.stringify(body),
|
|
77
|
-
}, {
|
|
78
|
-
decodeError: (message) => new errors_1.RpcError(message),
|
|
79
|
-
httpError: (message, response, body) => new errors_1.RpcError(message, {
|
|
80
|
-
status: response.status,
|
|
81
|
-
body,
|
|
82
|
-
}),
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
async getPublicParams() {
|
|
86
|
-
const data = await this.get('/core/public-params');
|
|
87
|
-
return models_1.CorePublicParameters.fromRpc(data);
|
|
88
|
-
}
|
|
89
|
-
async getSupportedTokens() {
|
|
90
|
-
const data = await this.get('/core/tokens');
|
|
91
|
-
return models_1.SupportedTokensResponse.fromRpc(data);
|
|
92
|
-
}
|
|
93
|
-
async issueGuarantee(body) {
|
|
94
|
-
return this.post('/core/guarantees', body);
|
|
95
|
-
}
|
|
96
|
-
async createPaymentTab(body) {
|
|
97
|
-
return this.post('/core/payment-tabs', body);
|
|
98
|
-
}
|
|
99
|
-
async listSettledTabs(recipientAddress) {
|
|
100
|
-
return this.get(`/core/recipients/${recipientAddress}/settled-tabs`);
|
|
101
|
-
}
|
|
102
|
-
async listPendingRemunerations(recipientAddress) {
|
|
103
|
-
return this.get(`/core/recipients/${recipientAddress}/pending-remunerations`);
|
|
104
|
-
}
|
|
105
|
-
async getTab(tabId) {
|
|
106
|
-
return this.get(`/core/tabs/${serializeTabId(tabId)}`);
|
|
107
|
-
}
|
|
108
|
-
async listRecipientTabs(recipientAddress, settlementStatuses) {
|
|
109
|
-
let query = '';
|
|
110
|
-
if (settlementStatuses?.length) {
|
|
111
|
-
query =
|
|
112
|
-
'?' + settlementStatuses.map((s) => `settlement_status=${encodeURIComponent(s)}`).join('&');
|
|
113
|
-
}
|
|
114
|
-
return this.get(`/core/recipients/${recipientAddress}/tabs${query}`);
|
|
115
|
-
}
|
|
116
|
-
async listUserTabs(userAddress, settlementStatuses) {
|
|
117
|
-
let query = '';
|
|
118
|
-
if (settlementStatuses?.length) {
|
|
119
|
-
query =
|
|
120
|
-
'?' + settlementStatuses.map((s) => `settlement_status=${encodeURIComponent(s)}`).join('&');
|
|
121
|
-
}
|
|
122
|
-
return this.get(`/core/users/${userAddress}/tabs${query}`);
|
|
123
|
-
}
|
|
124
|
-
async getTabGuarantees(tabId) {
|
|
125
|
-
return this.get(`/core/tabs/${serializeTabId(tabId)}/guarantees`);
|
|
126
|
-
}
|
|
127
|
-
async getLatestGuarantee(tabId) {
|
|
128
|
-
return this.get(`/core/tabs/${serializeTabId(tabId)}/guarantees/latest`);
|
|
129
|
-
}
|
|
130
|
-
async getGuarantee(tabId, reqId) {
|
|
131
|
-
return this.get(`/core/tabs/${serializeTabId(tabId)}/guarantees/${reqId}`);
|
|
132
|
-
}
|
|
133
|
-
async listRecipientPayments(recipientAddress) {
|
|
134
|
-
return this.get(`/core/recipients/${recipientAddress}/payments`);
|
|
135
|
-
}
|
|
136
|
-
async getCollateralEventsForTab(tabId) {
|
|
137
|
-
return this.get(`/core/tabs/${serializeTabId(tabId)}/collateral-events`);
|
|
138
|
-
}
|
|
139
|
-
async getUserAssetBalance(userAddress, assetAddress) {
|
|
140
|
-
return this.get(`/core/users/${userAddress}/assets/${assetAddress}`);
|
|
141
|
-
}
|
|
142
|
-
async updateUserSuspension(userAddress, suspended) {
|
|
143
|
-
const data = await this.post(`/core/users/${userAddress}/suspension`, {
|
|
144
|
-
suspended,
|
|
145
|
-
});
|
|
146
|
-
return models_1.UserSuspensionStatus.fromRpc(data);
|
|
147
|
-
}
|
|
148
|
-
async createAdminApiKey(body) {
|
|
149
|
-
const data = await this.post('/core/admin/api-keys', body);
|
|
150
|
-
return models_1.AdminApiKeySecret.fromRpc(data);
|
|
151
|
-
}
|
|
152
|
-
async listAdminApiKeys() {
|
|
153
|
-
const data = await this.get('/core/admin/api-keys');
|
|
154
|
-
return data.map((entry) => models_1.AdminApiKeyInfo.fromRpc(entry));
|
|
155
|
-
}
|
|
156
|
-
async revokeAdminApiKey(keyId) {
|
|
157
|
-
const data = await this.post(`/core/admin/api-keys/${keyId}/revoke`, {});
|
|
158
|
-
return models_1.AdminApiKeyInfo.fromRpc(data);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
exports.RpcProxy = RpcProxy;
|
package/dist/src/serde.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type RecordValue = Record<string, unknown>;
|
|
2
|
-
export declare const isRecord: (value: unknown) => value is RecordValue;
|
|
3
|
-
export declare function getAny<T>(raw: RecordValue, ...keys: string[]): T | undefined;
|
|
4
|
-
export declare function readString(value: unknown, label: string, onError: (label: string) => Error): string;
|
|
5
|
-
export declare function readNumber(value: unknown, label: string, onError: (label: string) => Error): number;
|
package/dist/src/serde.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRecord = void 0;
|
|
4
|
-
exports.getAny = getAny;
|
|
5
|
-
exports.readString = readString;
|
|
6
|
-
exports.readNumber = readNumber;
|
|
7
|
-
const isRecord = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
8
|
-
exports.isRecord = isRecord;
|
|
9
|
-
function getAny(raw, ...keys) {
|
|
10
|
-
for (const key of keys) {
|
|
11
|
-
if (key in raw)
|
|
12
|
-
return raw[key];
|
|
13
|
-
}
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
function readString(value, label, onError) {
|
|
17
|
-
if (typeof value === 'string' && value.trim()) {
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
throw onError(label);
|
|
21
|
-
}
|
|
22
|
-
function readNumber(value, label, onError) {
|
|
23
|
-
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
if (typeof value === 'string' && value.trim()) {
|
|
27
|
-
const parsed = Number(value);
|
|
28
|
-
if (Number.isFinite(parsed)) {
|
|
29
|
-
return parsed;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
throw onError(label);
|
|
33
|
-
}
|
package/dist/src/signing.d.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { Account, type Hex } from 'viem';
|
|
2
|
-
export { computeValidationSubjectHash, computeValidationRequestHash } from './validation';
|
|
3
|
-
import { CorePublicParameters, PaymentGuaranteeRequestClaims, PaymentGuaranteeRequestClaimsV2, PaymentSignature, SigningScheme } from './models';
|
|
4
|
-
export declare const GUARANTEE_EIP712_TYPES: {
|
|
5
|
-
readonly EIP712Domain: readonly [{
|
|
6
|
-
readonly name: "name";
|
|
7
|
-
readonly type: "string";
|
|
8
|
-
}, {
|
|
9
|
-
readonly name: "version";
|
|
10
|
-
readonly type: "string";
|
|
11
|
-
}, {
|
|
12
|
-
readonly name: "chainId";
|
|
13
|
-
readonly type: "uint256";
|
|
14
|
-
}];
|
|
15
|
-
readonly SolGuaranteeRequestClaimsV1: readonly [{
|
|
16
|
-
readonly name: "user";
|
|
17
|
-
readonly type: "address";
|
|
18
|
-
}, {
|
|
19
|
-
readonly name: "recipient";
|
|
20
|
-
readonly type: "address";
|
|
21
|
-
}, {
|
|
22
|
-
readonly name: "tabId";
|
|
23
|
-
readonly type: "uint256";
|
|
24
|
-
}, {
|
|
25
|
-
readonly name: "reqId";
|
|
26
|
-
readonly type: "uint256";
|
|
27
|
-
}, {
|
|
28
|
-
readonly name: "amount";
|
|
29
|
-
readonly type: "uint256";
|
|
30
|
-
}, {
|
|
31
|
-
readonly name: "asset";
|
|
32
|
-
readonly type: "address";
|
|
33
|
-
}, {
|
|
34
|
-
readonly name: "timestamp";
|
|
35
|
-
readonly type: "uint64";
|
|
36
|
-
}];
|
|
37
|
-
};
|
|
38
|
-
export declare const GUARANTEE_EIP712_TYPES_V2: {
|
|
39
|
-
readonly EIP712Domain: readonly [{
|
|
40
|
-
readonly name: "name";
|
|
41
|
-
readonly type: "string";
|
|
42
|
-
}, {
|
|
43
|
-
readonly name: "version";
|
|
44
|
-
readonly type: "string";
|
|
45
|
-
}, {
|
|
46
|
-
readonly name: "chainId";
|
|
47
|
-
readonly type: "uint256";
|
|
48
|
-
}];
|
|
49
|
-
readonly SolGuaranteeRequestClaimsV2: readonly [{
|
|
50
|
-
readonly name: "user";
|
|
51
|
-
readonly type: "address";
|
|
52
|
-
}, {
|
|
53
|
-
readonly name: "recipient";
|
|
54
|
-
readonly type: "address";
|
|
55
|
-
}, {
|
|
56
|
-
readonly name: "tabId";
|
|
57
|
-
readonly type: "uint256";
|
|
58
|
-
}, {
|
|
59
|
-
readonly name: "reqId";
|
|
60
|
-
readonly type: "uint256";
|
|
61
|
-
}, {
|
|
62
|
-
readonly name: "amount";
|
|
63
|
-
readonly type: "uint256";
|
|
64
|
-
}, {
|
|
65
|
-
readonly name: "asset";
|
|
66
|
-
readonly type: "address";
|
|
67
|
-
}, {
|
|
68
|
-
readonly name: "timestamp";
|
|
69
|
-
readonly type: "uint64";
|
|
70
|
-
}, {
|
|
71
|
-
readonly name: "validationRegistryAddress";
|
|
72
|
-
readonly type: "address";
|
|
73
|
-
}, {
|
|
74
|
-
readonly name: "validationRequestHash";
|
|
75
|
-
readonly type: "bytes32";
|
|
76
|
-
}, {
|
|
77
|
-
readonly name: "validationChainId";
|
|
78
|
-
readonly type: "uint256";
|
|
79
|
-
}, {
|
|
80
|
-
readonly name: "validatorAddress";
|
|
81
|
-
readonly type: "address";
|
|
82
|
-
}, {
|
|
83
|
-
readonly name: "validatorAgentId";
|
|
84
|
-
readonly type: "uint256";
|
|
85
|
-
}, {
|
|
86
|
-
readonly name: "minValidationScore";
|
|
87
|
-
readonly type: "uint8";
|
|
88
|
-
}, {
|
|
89
|
-
readonly name: "validationSubjectHash";
|
|
90
|
-
readonly type: "bytes32";
|
|
91
|
-
}, {
|
|
92
|
-
readonly name: "jobHash";
|
|
93
|
-
readonly type: "bytes32";
|
|
94
|
-
}, {
|
|
95
|
-
readonly name: "requiredValidationTag";
|
|
96
|
-
readonly type: "string";
|
|
97
|
-
}];
|
|
98
|
-
};
|
|
99
|
-
export type GuaranteeTypedData = {
|
|
100
|
-
types: typeof GUARANTEE_EIP712_TYPES;
|
|
101
|
-
primaryType: 'SolGuaranteeRequestClaimsV1';
|
|
102
|
-
domain: {
|
|
103
|
-
name: string;
|
|
104
|
-
version: string;
|
|
105
|
-
chainId: number;
|
|
106
|
-
};
|
|
107
|
-
message: {
|
|
108
|
-
user: Hex;
|
|
109
|
-
recipient: Hex;
|
|
110
|
-
tabId: bigint;
|
|
111
|
-
reqId: bigint;
|
|
112
|
-
amount: bigint;
|
|
113
|
-
asset: Hex;
|
|
114
|
-
timestamp: bigint;
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
export type GuaranteeTypedDataV2 = {
|
|
118
|
-
types: typeof GUARANTEE_EIP712_TYPES_V2;
|
|
119
|
-
primaryType: 'SolGuaranteeRequestClaimsV2';
|
|
120
|
-
domain: {
|
|
121
|
-
name: string;
|
|
122
|
-
version: string;
|
|
123
|
-
chainId: number;
|
|
124
|
-
};
|
|
125
|
-
message: {
|
|
126
|
-
user: Hex;
|
|
127
|
-
recipient: Hex;
|
|
128
|
-
tabId: bigint;
|
|
129
|
-
reqId: bigint;
|
|
130
|
-
amount: bigint;
|
|
131
|
-
asset: Hex;
|
|
132
|
-
timestamp: bigint;
|
|
133
|
-
validationRegistryAddress: Hex;
|
|
134
|
-
validationRequestHash: Hex;
|
|
135
|
-
validationChainId: bigint;
|
|
136
|
-
validatorAddress: Hex;
|
|
137
|
-
validatorAgentId: bigint;
|
|
138
|
-
minValidationScore: number;
|
|
139
|
-
validationSubjectHash: Hex;
|
|
140
|
-
jobHash: Hex;
|
|
141
|
-
requiredValidationTag: string;
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
export type GuaranteeTypedDataValidationOptions = {
|
|
145
|
-
expectedChainId?: number;
|
|
146
|
-
expectedSigner?: string;
|
|
147
|
-
expectedRecipient?: string;
|
|
148
|
-
};
|
|
149
|
-
export type GuaranteeSigningContextOptions = {
|
|
150
|
-
signerAddress?: string;
|
|
151
|
-
signerChainId?: number;
|
|
152
|
-
};
|
|
153
|
-
export declare function validateGuaranteeTypedData(payload: {
|
|
154
|
-
domain: Record<string, unknown>;
|
|
155
|
-
types: Record<string, Array<{
|
|
156
|
-
name: string;
|
|
157
|
-
type: string;
|
|
158
|
-
}>>;
|
|
159
|
-
message: Record<string, unknown>;
|
|
160
|
-
}, options?: GuaranteeTypedDataValidationOptions): void;
|
|
161
|
-
export declare function validateGuaranteeSigningContext(params: CorePublicParameters, claims: PaymentGuaranteeRequestClaims, options?: GuaranteeSigningContextOptions): void;
|
|
162
|
-
export declare function buildGuaranteeTypedData(params: CorePublicParameters, claims: PaymentGuaranteeRequestClaims): GuaranteeTypedData;
|
|
163
|
-
export declare function buildGuaranteeTypedDataV2(params: CorePublicParameters, claims: PaymentGuaranteeRequestClaimsV2): GuaranteeTypedDataV2;
|
|
164
|
-
export declare function encodeGuaranteeEip191V2(claims: PaymentGuaranteeRequestClaimsV2): string;
|
|
165
|
-
export declare function encodeGuaranteeEip191(claims: PaymentGuaranteeRequestClaims): string;
|
|
166
|
-
export declare class PaymentSigner {
|
|
167
|
-
readonly signer: Account;
|
|
168
|
-
constructor(signer: Account);
|
|
169
|
-
signRequest(params: CorePublicParameters, claims: PaymentGuaranteeRequestClaims | PaymentGuaranteeRequestClaimsV2, scheme?: SigningScheme): Promise<PaymentSignature>;
|
|
170
|
-
}
|