@trusset/sdk 0.1.0 → 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/README.md +175 -171
- package/dist/base-BYEauvBZ.d.mts +111 -0
- package/dist/base-zODt0Kf5.d.ts +111 -0
- package/dist/chunk-2KHUPARH.js +2260 -0
- package/dist/chunk-3YF42MHV.mjs +678 -0
- package/dist/chunk-4MNJZAXE.mjs +2260 -0
- package/dist/chunk-7HFMHYRA.js +107 -0
- package/dist/chunk-ACXAKW5E.js +916 -0
- package/dist/chunk-AI4ZNJLR.js +678 -0
- package/dist/chunk-C7CANC53.mjs +208 -0
- package/dist/chunk-DQCX2GYT.mjs +107 -0
- package/dist/chunk-GWMT6UU7.js +208 -0
- package/dist/chunk-OQG3PEF3.mjs +916 -0
- package/dist/flow-Cz8A09rn.d.mts +171 -0
- package/dist/flow-Cz8A09rn.d.ts +171 -0
- package/dist/index-DKUSzkBN.d.ts +956 -0
- package/dist/index-Dl4U8vUM.d.mts +956 -0
- package/dist/index.d.mts +39 -448
- package/dist/index.d.ts +39 -448
- package/dist/index.js +264 -534
- package/dist/index.mjs +249 -483
- package/dist/modules/customers/index.d.mts +2 -0
- package/dist/modules/customers/index.d.ts +2 -0
- package/dist/modules/customers/index.js +17 -0
- package/dist/modules/customers/index.mjs +17 -0
- package/dist/modules/lending/index.d.mts +6768 -0
- package/dist/modules/lending/index.d.ts +6768 -0
- package/dist/modules/lending/index.js +44 -0
- package/dist/modules/lending/index.mjs +44 -0
- package/dist/modules/tokens/index.d.mts +476 -0
- package/dist/modules/tokens/index.d.ts +476 -0
- package/dist/modules/tokens/index.js +8 -0
- package/dist/modules/tokens/index.mjs +8 -0
- package/package.json +71 -35
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base API response envelope returned by all Trusset endpoints.
|
|
3
|
+
*/
|
|
4
|
+
interface ApiResponse<T> {
|
|
5
|
+
success: boolean;
|
|
6
|
+
data?: T;
|
|
7
|
+
error?: ApiError;
|
|
8
|
+
metadata: ResponseMetadata;
|
|
9
|
+
}
|
|
10
|
+
interface ApiError {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
details?: unknown;
|
|
14
|
+
}
|
|
15
|
+
interface ResponseMetadata {
|
|
16
|
+
requestId: string;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
total?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* SDK configuration passed to TrussetClient on init.
|
|
22
|
+
*/
|
|
23
|
+
interface TrussetConfig {
|
|
24
|
+
/** API key from the Trusset issuer dashboard. */
|
|
25
|
+
apiKey: string;
|
|
26
|
+
/**
|
|
27
|
+
* Base URL of the Trusset API.
|
|
28
|
+
* Defaults to https://api.trusset.org
|
|
29
|
+
*/
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Request timeout in milliseconds. Default: 30000 (30s).
|
|
33
|
+
*/
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Max retries on transient failures (5xx, network). Default: 3.
|
|
37
|
+
*/
|
|
38
|
+
maxRetries?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Custom logger. Defaults to silent.
|
|
41
|
+
*/
|
|
42
|
+
logger?: Logger;
|
|
43
|
+
}
|
|
44
|
+
interface Logger {
|
|
45
|
+
debug(msg: string, meta?: Record<string, unknown>): void;
|
|
46
|
+
info(msg: string, meta?: Record<string, unknown>): void;
|
|
47
|
+
warn(msg: string, meta?: Record<string, unknown>): void;
|
|
48
|
+
error(msg: string, meta?: Record<string, unknown>): void;
|
|
49
|
+
}
|
|
50
|
+
interface PaginationOptions {
|
|
51
|
+
limit?: number;
|
|
52
|
+
offset?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A broadcast transaction, as returned by a signer's `sendTransaction`.
|
|
56
|
+
* Matches the shape of an ethers v5 `TransactionResponse`.
|
|
57
|
+
*/
|
|
58
|
+
interface SignedTransaction {
|
|
59
|
+
hash: string;
|
|
60
|
+
wait(confirmations?: number): Promise<unknown>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Anything that can sign and broadcast a transaction. An ethers v5 `Signer`
|
|
64
|
+
* (`Wallet`, `JsonRpcSigner`, ...) satisfies this without any adapter.
|
|
65
|
+
*
|
|
66
|
+
* Trusset never holds a key: on-chain writes return unsigned calldata that
|
|
67
|
+
* the wallet holder signs. The signer you pass must be the registered issuer
|
|
68
|
+
* wallet, since the identity registry checks its role on-chain.
|
|
69
|
+
*/
|
|
70
|
+
interface TransactionSigner {
|
|
71
|
+
sendTransaction(transaction: UnsignedTransaction): Promise<SignedTransaction>;
|
|
72
|
+
getAddress?(): Promise<string>;
|
|
73
|
+
getChainId?(): Promise<number>;
|
|
74
|
+
_signTypedData?(domain: Record<string, unknown>, types: Record<string, Array<{
|
|
75
|
+
name: string;
|
|
76
|
+
type: string;
|
|
77
|
+
}>>, value: Record<string, unknown>): Promise<string>;
|
|
78
|
+
signMessage?(message: string | Uint8Array): Promise<string>;
|
|
79
|
+
estimateGas?(transaction: UnsignedTransaction): Promise<{
|
|
80
|
+
toString(): string;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
interface UnsignedTransaction {
|
|
84
|
+
to?: string;
|
|
85
|
+
data: string;
|
|
86
|
+
value?: string;
|
|
87
|
+
chainId?: number;
|
|
88
|
+
gasLimit?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sign and broadcast the prepared transaction, then confirm it with the
|
|
92
|
+
* backend. Convenience only - the SDK does not verify the calldata it was
|
|
93
|
+
* handed. If your integration depends on the transaction doing exactly what
|
|
94
|
+
* you asked, decode and assert `transaction.to` and `transaction.data`
|
|
95
|
+
* yourself, in your own pinned code, before signing.
|
|
96
|
+
*/
|
|
97
|
+
interface SignOptions {
|
|
98
|
+
signer: TransactionSigner;
|
|
99
|
+
/** Confirmations to wait for before confirming with the backend. Default: 1. */
|
|
100
|
+
confirmations?: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Confirm a transaction you signed and broadcast yourself. The backend reads
|
|
104
|
+
* the mined receipt and only then updates its records.
|
|
105
|
+
*/
|
|
106
|
+
interface ConfirmOptions {
|
|
107
|
+
txHash: string;
|
|
108
|
+
}
|
|
109
|
+
interface SignedStep {
|
|
110
|
+
functionName: string | null;
|
|
111
|
+
txHash: string | null;
|
|
112
|
+
optional: boolean;
|
|
113
|
+
error?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
type FetchLike = (input: string, init: RequestInit) => Promise<Response>;
|
|
117
|
+
interface HttpClientConfig {
|
|
118
|
+
baseUrl: string;
|
|
119
|
+
apiKey: string;
|
|
120
|
+
timeoutMs: number;
|
|
121
|
+
maxRetries: number;
|
|
122
|
+
logger: Logger;
|
|
123
|
+
fetch: FetchLike;
|
|
124
|
+
}
|
|
125
|
+
type RetryClass = 'read' | 'write' | 'confirm';
|
|
126
|
+
interface RequestOptions {
|
|
127
|
+
timeoutMs?: number;
|
|
128
|
+
retry?: RetryClass;
|
|
129
|
+
}
|
|
130
|
+
interface BinaryResponse {
|
|
131
|
+
bytes: Uint8Array;
|
|
132
|
+
contentType: string;
|
|
133
|
+
filename: string | null;
|
|
134
|
+
}
|
|
135
|
+
type Params = Record<string, string | number | boolean | undefined>;
|
|
136
|
+
declare class HttpClient {
|
|
137
|
+
private readonly config;
|
|
138
|
+
constructor(config: Partial<HttpClientConfig> & {
|
|
139
|
+
apiKey: string;
|
|
140
|
+
});
|
|
141
|
+
get<T>(path: string, params?: Params, options?: RequestOptions): Promise<T>;
|
|
142
|
+
/** GET that also returns the response metadata (used for list totals). */
|
|
143
|
+
getWithMeta<T>(path: string, params?: Params): Promise<{
|
|
144
|
+
data: T;
|
|
145
|
+
metadata: ResponseMetadata;
|
|
146
|
+
}>;
|
|
147
|
+
getBinary(path: string, params?: Params, options?: RequestOptions): Promise<BinaryResponse>;
|
|
148
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
149
|
+
put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
150
|
+
patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
151
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
152
|
+
postForm<T>(path: string, form: FormData, params?: Params, options?: RequestOptions): Promise<T>;
|
|
153
|
+
private buildUrl;
|
|
154
|
+
private retryClass;
|
|
155
|
+
private canRetry;
|
|
156
|
+
private headers;
|
|
157
|
+
private send;
|
|
158
|
+
private requestEnvelope;
|
|
159
|
+
private requestBinary;
|
|
160
|
+
private throwIfFailed;
|
|
161
|
+
private withRetries;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface ChainSource {
|
|
165
|
+
instanceChainId(): Promise<number>;
|
|
166
|
+
}
|
|
167
|
+
interface PlanOptions {
|
|
168
|
+
confirmIndex?: number | 'last' | null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export { type ApiError as A, type ConfirmOptions as C, HttpClient as H, type Logger as L, type PaginationOptions as P, type ResponseMetadata as R, type SignedStep as S, type TrussetConfig as T, type UnsignedTransaction as U, type ApiResponse as a, type SignOptions as b, type SignedTransaction as c, type TransactionSigner as d, type ChainSource as e, type PlanOptions as f };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base API response envelope returned by all Trusset endpoints.
|
|
3
|
+
*/
|
|
4
|
+
interface ApiResponse<T> {
|
|
5
|
+
success: boolean;
|
|
6
|
+
data?: T;
|
|
7
|
+
error?: ApiError;
|
|
8
|
+
metadata: ResponseMetadata;
|
|
9
|
+
}
|
|
10
|
+
interface ApiError {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
details?: unknown;
|
|
14
|
+
}
|
|
15
|
+
interface ResponseMetadata {
|
|
16
|
+
requestId: string;
|
|
17
|
+
timestamp: string;
|
|
18
|
+
total?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* SDK configuration passed to TrussetClient on init.
|
|
22
|
+
*/
|
|
23
|
+
interface TrussetConfig {
|
|
24
|
+
/** API key from the Trusset issuer dashboard. */
|
|
25
|
+
apiKey: string;
|
|
26
|
+
/**
|
|
27
|
+
* Base URL of the Trusset API.
|
|
28
|
+
* Defaults to https://api.trusset.org
|
|
29
|
+
*/
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Request timeout in milliseconds. Default: 30000 (30s).
|
|
33
|
+
*/
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Max retries on transient failures (5xx, network). Default: 3.
|
|
37
|
+
*/
|
|
38
|
+
maxRetries?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Custom logger. Defaults to silent.
|
|
41
|
+
*/
|
|
42
|
+
logger?: Logger;
|
|
43
|
+
}
|
|
44
|
+
interface Logger {
|
|
45
|
+
debug(msg: string, meta?: Record<string, unknown>): void;
|
|
46
|
+
info(msg: string, meta?: Record<string, unknown>): void;
|
|
47
|
+
warn(msg: string, meta?: Record<string, unknown>): void;
|
|
48
|
+
error(msg: string, meta?: Record<string, unknown>): void;
|
|
49
|
+
}
|
|
50
|
+
interface PaginationOptions {
|
|
51
|
+
limit?: number;
|
|
52
|
+
offset?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A broadcast transaction, as returned by a signer's `sendTransaction`.
|
|
56
|
+
* Matches the shape of an ethers v5 `TransactionResponse`.
|
|
57
|
+
*/
|
|
58
|
+
interface SignedTransaction {
|
|
59
|
+
hash: string;
|
|
60
|
+
wait(confirmations?: number): Promise<unknown>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Anything that can sign and broadcast a transaction. An ethers v5 `Signer`
|
|
64
|
+
* (`Wallet`, `JsonRpcSigner`, ...) satisfies this without any adapter.
|
|
65
|
+
*
|
|
66
|
+
* Trusset never holds a key: on-chain writes return unsigned calldata that
|
|
67
|
+
* the wallet holder signs. The signer you pass must be the registered issuer
|
|
68
|
+
* wallet, since the identity registry checks its role on-chain.
|
|
69
|
+
*/
|
|
70
|
+
interface TransactionSigner {
|
|
71
|
+
sendTransaction(transaction: UnsignedTransaction): Promise<SignedTransaction>;
|
|
72
|
+
getAddress?(): Promise<string>;
|
|
73
|
+
getChainId?(): Promise<number>;
|
|
74
|
+
_signTypedData?(domain: Record<string, unknown>, types: Record<string, Array<{
|
|
75
|
+
name: string;
|
|
76
|
+
type: string;
|
|
77
|
+
}>>, value: Record<string, unknown>): Promise<string>;
|
|
78
|
+
signMessage?(message: string | Uint8Array): Promise<string>;
|
|
79
|
+
estimateGas?(transaction: UnsignedTransaction): Promise<{
|
|
80
|
+
toString(): string;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
interface UnsignedTransaction {
|
|
84
|
+
to?: string;
|
|
85
|
+
data: string;
|
|
86
|
+
value?: string;
|
|
87
|
+
chainId?: number;
|
|
88
|
+
gasLimit?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sign and broadcast the prepared transaction, then confirm it with the
|
|
92
|
+
* backend. Convenience only - the SDK does not verify the calldata it was
|
|
93
|
+
* handed. If your integration depends on the transaction doing exactly what
|
|
94
|
+
* you asked, decode and assert `transaction.to` and `transaction.data`
|
|
95
|
+
* yourself, in your own pinned code, before signing.
|
|
96
|
+
*/
|
|
97
|
+
interface SignOptions {
|
|
98
|
+
signer: TransactionSigner;
|
|
99
|
+
/** Confirmations to wait for before confirming with the backend. Default: 1. */
|
|
100
|
+
confirmations?: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Confirm a transaction you signed and broadcast yourself. The backend reads
|
|
104
|
+
* the mined receipt and only then updates its records.
|
|
105
|
+
*/
|
|
106
|
+
interface ConfirmOptions {
|
|
107
|
+
txHash: string;
|
|
108
|
+
}
|
|
109
|
+
interface SignedStep {
|
|
110
|
+
functionName: string | null;
|
|
111
|
+
txHash: string | null;
|
|
112
|
+
optional: boolean;
|
|
113
|
+
error?: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
type FetchLike = (input: string, init: RequestInit) => Promise<Response>;
|
|
117
|
+
interface HttpClientConfig {
|
|
118
|
+
baseUrl: string;
|
|
119
|
+
apiKey: string;
|
|
120
|
+
timeoutMs: number;
|
|
121
|
+
maxRetries: number;
|
|
122
|
+
logger: Logger;
|
|
123
|
+
fetch: FetchLike;
|
|
124
|
+
}
|
|
125
|
+
type RetryClass = 'read' | 'write' | 'confirm';
|
|
126
|
+
interface RequestOptions {
|
|
127
|
+
timeoutMs?: number;
|
|
128
|
+
retry?: RetryClass;
|
|
129
|
+
}
|
|
130
|
+
interface BinaryResponse {
|
|
131
|
+
bytes: Uint8Array;
|
|
132
|
+
contentType: string;
|
|
133
|
+
filename: string | null;
|
|
134
|
+
}
|
|
135
|
+
type Params = Record<string, string | number | boolean | undefined>;
|
|
136
|
+
declare class HttpClient {
|
|
137
|
+
private readonly config;
|
|
138
|
+
constructor(config: Partial<HttpClientConfig> & {
|
|
139
|
+
apiKey: string;
|
|
140
|
+
});
|
|
141
|
+
get<T>(path: string, params?: Params, options?: RequestOptions): Promise<T>;
|
|
142
|
+
/** GET that also returns the response metadata (used for list totals). */
|
|
143
|
+
getWithMeta<T>(path: string, params?: Params): Promise<{
|
|
144
|
+
data: T;
|
|
145
|
+
metadata: ResponseMetadata;
|
|
146
|
+
}>;
|
|
147
|
+
getBinary(path: string, params?: Params, options?: RequestOptions): Promise<BinaryResponse>;
|
|
148
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
149
|
+
put<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
150
|
+
patch<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
151
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
152
|
+
postForm<T>(path: string, form: FormData, params?: Params, options?: RequestOptions): Promise<T>;
|
|
153
|
+
private buildUrl;
|
|
154
|
+
private retryClass;
|
|
155
|
+
private canRetry;
|
|
156
|
+
private headers;
|
|
157
|
+
private send;
|
|
158
|
+
private requestEnvelope;
|
|
159
|
+
private requestBinary;
|
|
160
|
+
private throwIfFailed;
|
|
161
|
+
private withRetries;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface ChainSource {
|
|
165
|
+
instanceChainId(): Promise<number>;
|
|
166
|
+
}
|
|
167
|
+
interface PlanOptions {
|
|
168
|
+
confirmIndex?: number | 'last' | null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export { type ApiError as A, type ConfirmOptions as C, HttpClient as H, type Logger as L, type PaginationOptions as P, type ResponseMetadata as R, type SignedStep as S, type TrussetConfig as T, type UnsignedTransaction as U, type ApiResponse as a, type SignOptions as b, type SignedTransaction as c, type TransactionSigner as d, type ChainSource as e, type PlanOptions as f };
|