infra-sdk-typescript 0.1.1 → 0.1.3
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 +79 -74
- package/dist/index.d.cts +28 -17
- package/dist/index.d.ts +28 -17
- package/package.json +77 -77
package/README.md
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
# infra-sdk-typescript
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
**Wallet**, **Tokenization**, and **Blockchain Events (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
-
|
|
3
|
+
The official TypeScript SDK for the [Convexity Infra API](https://docs.withconvexity.com).
|
|
4
|
+
It covers three services: **Wallet**, **Tokenization**, and **Blockchain Events** (the
|
|
5
|
+
Indexer).
|
|
6
|
+
|
|
7
|
+
What you get:
|
|
8
|
+
|
|
9
|
+
- Types for every request and response, including all three of the pagination envelopes
|
|
10
|
+
the API uses.
|
|
11
|
+
- Auth handled for you. Hand the client an API key and it mints, caches, and refreshes
|
|
12
|
+
OAuth bearer tokens in the background.
|
|
13
|
+
- Retries with backoff on rate limits (`429`, honoring `retryAfter`) and upstream outages
|
|
14
|
+
(`503`). Connection failures get retried too, but only when a retry is safe.
|
|
15
|
+
- `Idempotency-Key` headers generated automatically on the wallet operations that move
|
|
16
|
+
value. You can pass your own instead.
|
|
17
|
+
- Real error classes (`RateLimitError`, `NotFoundError`, `PaymentRequiredError`, and so
|
|
18
|
+
on) so you're not switching on status codes.
|
|
19
|
+
- Signature verification for both webhook schemes: Wallet outcome webhooks and Indexer
|
|
20
|
+
event deliveries.
|
|
21
|
+
- No runtime dependencies. It's built on native `fetch` and `node:crypto`, and ships dual
|
|
20
22
|
ESM/CJS builds with full `.d.ts` types.
|
|
21
23
|
|
|
22
24
|
## Requirements
|
|
23
25
|
|
|
24
26
|
- Node.js 18 or later.
|
|
25
|
-
- A Convexity Infra API key. There's no self-service signup
|
|
26
|
-
[infra@withconvexity.com](mailto:infra@withconvexity.com) with your business details
|
|
27
|
-
get a test key (`sk_test_...`) and a live key (`sk_live_...`).
|
|
27
|
+
- A Convexity Infra API key. There's no self-service signup yet, so email
|
|
28
|
+
[infra@withconvexity.com](mailto:infra@withconvexity.com) with your business details and
|
|
29
|
+
you'll get back a test key (`sk_test_...`) and a live key (`sk_live_...`).
|
|
28
30
|
|
|
29
31
|
## Install
|
|
30
32
|
|
|
@@ -43,24 +45,26 @@ const balance = await client.wallet.getBalance();
|
|
|
43
45
|
console.log(`Business balance: $${balance.balance}`);
|
|
44
46
|
```
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
(`POST /v1/oauth/token`)
|
|
48
|
-
|
|
48
|
+
On the first call, the client trades your API key for a short-lived OAuth bearer token
|
|
49
|
+
(`POST /v1/oauth/token`) and caches it. It refreshes that token before it expires, and
|
|
50
|
+
retries once if it ever gets a surprise `401`. You shouldn't need to touch tokens yourself.
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
There are fuller examples in [`examples/`](./examples):
|
|
51
53
|
|
|
52
|
-
- [`basic-usage.ts`](./examples/basic-usage.ts)
|
|
53
|
-
|
|
54
|
-
- [`
|
|
55
|
-
|
|
56
|
-
- [`
|
|
57
|
-
|
|
58
|
-
- [`
|
|
59
|
-
|
|
54
|
+
- [`basic-usage.ts`](./examples/basic-usage.ts) derives a wallet, transfers, and polls for
|
|
55
|
+
completion.
|
|
56
|
+
- [`pagination.ts`](./examples/pagination.ts) shows all three ways to consume a paginated
|
|
57
|
+
list.
|
|
58
|
+
- [`tokenization-yield-lifecycle.ts`](./examples/tokenization-yield-lifecycle.ts) walks a
|
|
59
|
+
yield-bearing token from issue through mint, coupon payment, and principal redemption.
|
|
60
|
+
- [`indexer-subscription.ts`](./examples/indexer-subscription.ts) subscribes to on-chain
|
|
61
|
+
events and manages the subscription afterward.
|
|
62
|
+
- [`webhook-verification.ts`](./examples/webhook-verification.ts) verifies both signature
|
|
63
|
+
schemes inside a plain `node:http` server.
|
|
60
64
|
|
|
61
65
|
## Resources
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
There's one namespace per service:
|
|
64
68
|
|
|
65
69
|
| Namespace | Service | Docs |
|
|
66
70
|
|---|---|---|
|
|
@@ -68,15 +72,15 @@ The client exposes one namespace per service:
|
|
|
68
72
|
| `client.tokenization` | Issue, mint/burn/transfer tokenized assets; yield lifecycle | [Tokenization overview](https://docs.withconvexity.com/api-reference/tokenization/overview) |
|
|
69
73
|
| `client.indexer` | Subscribe to decoded on-chain events, delivered to your webhook | [Blockchain Events overview](https://docs.withconvexity.com/api-reference/indexer/overview) |
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
The methods map 1:1 onto the API. Check the JSDoc on each resource, or the type
|
|
76
|
+
definitions, for full parameter and return shapes. A few things worth calling out:
|
|
73
77
|
|
|
74
78
|
### Async transfers
|
|
75
79
|
|
|
76
80
|
[`initiateTransfer`](./src/resources/wallet/index.ts) and
|
|
77
|
-
[`signTransaction`](./src/resources/wallet/index.ts) are
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
[`signTransaction`](./src/resources/wallet/index.ts) are async by default. They hand back a
|
|
82
|
+
`PENDING` transaction right away (HTTP `202`) and the on-chain execution keeps going in the
|
|
83
|
+
background.
|
|
80
84
|
|
|
81
85
|
```ts
|
|
82
86
|
const transfer = await client.wallet.initiateTransfer({
|
|
@@ -94,25 +98,25 @@ while (final.status === "PENDING" || final.status === "PROCESSING") {
|
|
|
94
98
|
final = await client.wallet.getTransaction(transfer.id);
|
|
95
99
|
}
|
|
96
100
|
|
|
97
|
-
// ...or
|
|
98
|
-
//
|
|
101
|
+
// ...or take the outcome at a webhook instead: pass webhookUrl/webhookSecret on the
|
|
102
|
+
// initiate call, then verify deliveries with `verifyWalletWebhookSignature`.
|
|
99
103
|
```
|
|
100
104
|
|
|
101
|
-
|
|
102
|
-
request open
|
|
105
|
+
If you want the old synchronous behavior, pass `waitForCompletion: true`. That holds the
|
|
106
|
+
request open until the transaction settles and returns the final result.
|
|
103
107
|
|
|
104
108
|
### Pagination
|
|
105
109
|
|
|
106
|
-
The API
|
|
107
|
-
|
|
110
|
+
The API hands back three different pagination envelopes depending on which service you're
|
|
111
|
+
hitting. The SDK flattens all of them into a single `Page<T>`:
|
|
108
112
|
|
|
109
113
|
```ts
|
|
110
|
-
//
|
|
114
|
+
// Iterate every item; later pages are fetched as you go.
|
|
111
115
|
for await (const token of await client.tokenization.listTokens()) {
|
|
112
116
|
console.log(token.ticker);
|
|
113
117
|
}
|
|
114
118
|
|
|
115
|
-
// Or walk page
|
|
119
|
+
// Or walk it a page at a time:
|
|
116
120
|
let page = await client.wallet.getTransactionHistory({ status: "COMPLETED" });
|
|
117
121
|
for (;;) {
|
|
118
122
|
for (const tx of page.data) handle(tx);
|
|
@@ -120,15 +124,15 @@ for (;;) {
|
|
|
120
124
|
page = await page.getNextPage();
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
// Or
|
|
127
|
+
// Or just pull the whole thing into memory, which is fine for small collections:
|
|
124
128
|
const holders = await (await client.tokenization.getTokenHolders({ tokenId })).toArray();
|
|
125
129
|
```
|
|
126
130
|
|
|
127
131
|
### Idempotency
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
`initiateTransfer`, `signTransaction`, and `generateWallets` all require an
|
|
134
|
+
`Idempotency-Key` header. The SDK generates a UUIDv4 per call. Pass your own when you need
|
|
135
|
+
a retry to line up across two separate SDK calls, like after a process restart:
|
|
132
136
|
|
|
133
137
|
```ts
|
|
134
138
|
await client.wallet.initiateTransfer(params, { idempotencyKey: "my-own-key" });
|
|
@@ -136,8 +140,8 @@ await client.wallet.initiateTransfer(params, { idempotencyKey: "my-own-key" });
|
|
|
136
140
|
|
|
137
141
|
### Errors
|
|
138
142
|
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
Everything the SDK throws extends `InfraError`. HTTP failures extend `InfraAPIError` and
|
|
144
|
+
line up with the status code table in the API docs:
|
|
141
145
|
|
|
142
146
|
```ts
|
|
143
147
|
import { RateLimitError, PaymentRequiredError, UnprocessableEntityError, InfraAPIError } from "infra-sdk-typescript";
|
|
@@ -150,8 +154,8 @@ try {
|
|
|
150
154
|
} else if (err instanceof PaymentRequiredError) {
|
|
151
155
|
console.log("Insufficient gas balance");
|
|
152
156
|
} else if (err instanceof UnprocessableEntityError) {
|
|
153
|
-
// waitForCompletion: true
|
|
154
|
-
// transaction
|
|
157
|
+
// A waitForCompletion: true transfer that reverts on-chain still carries the failed
|
|
158
|
+
// transaction. Read it off the raw response body if you need the details.
|
|
155
159
|
console.log((err.body as { data?: unknown }).data);
|
|
156
160
|
} else if (err instanceof InfraAPIError) {
|
|
157
161
|
console.log(err.status, err.message, err.errors);
|
|
@@ -159,17 +163,19 @@ try {
|
|
|
159
163
|
}
|
|
160
164
|
```
|
|
161
165
|
|
|
162
|
-
`429` and `503`
|
|
163
|
-
|
|
166
|
+
`429` and `503` get retried for you (twice by default). Everything else throws right away,
|
|
167
|
+
because sending the identical request again won't change the answer.
|
|
164
168
|
|
|
165
169
|
### Retries, timeouts, and connection safety
|
|
166
170
|
|
|
167
|
-
- `429` and `503` are retried
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
- `429` and `503` are always retried. The server never executed the request in either
|
|
172
|
+
case, so there's nothing to double up on. `429` retries wait for whatever `retryAfter`
|
|
173
|
+
says.
|
|
174
|
+
- Connection failures are murkier. If a request times out, or DNS fails, or TLS breaks, or
|
|
175
|
+
the socket aborts, you can't tell whether the server already ran it. So the SDK only
|
|
176
|
+
retries those on `GET` requests and on requests carrying an `Idempotency-Key`, where a
|
|
177
|
+
duplicate provably can't hurt.
|
|
178
|
+
- Set these on the constructor, or override them per call:
|
|
173
179
|
|
|
174
180
|
```ts
|
|
175
181
|
const client = new InfraClient({
|
|
@@ -187,31 +193,30 @@ await client.wallet.getBalance({ timeoutMs: 5_000, signal: myAbortController.sig
|
|
|
187
193
|
import { verifyWalletWebhookSignature, verifyIndexerWebhookSignature } from "infra-sdk-typescript";
|
|
188
194
|
|
|
189
195
|
// Wallet outcome webhooks (wallet.transfer.completed / .failed, wallet.sign.completed / .failed):
|
|
190
|
-
// HMAC-SHA256("<timestamp>.<rawBody>"), with a 5-minute replay
|
|
196
|
+
// HMAC-SHA256("<timestamp>.<rawBody>"), with a 5-minute replay window by default.
|
|
191
197
|
verifyWalletWebhookSignature({
|
|
192
|
-
payload: rawBody, // the
|
|
198
|
+
payload: rawBody, // exactly the bytes you received — don't JSON.parse and re-stringify
|
|
193
199
|
timestampHeader: req.headers["x-wallet-timestamp"],
|
|
194
200
|
signatureHeader: req.headers["x-wallet-signature"],
|
|
195
|
-
secret: webhookSecret, //
|
|
201
|
+
secret: webhookSecret, // whatever you passed as `webhookSecret` on the originating call
|
|
196
202
|
});
|
|
197
203
|
|
|
198
204
|
// Indexer (Blockchain Events) deliveries: HMAC-SHA256(rawBody), no timestamp component.
|
|
199
205
|
verifyIndexerWebhookSignature({
|
|
200
206
|
payload: rawBody,
|
|
201
207
|
signatureHeader: req.headers["x-indexer-signature"],
|
|
202
|
-
secret: signingSecret, // returned once,
|
|
208
|
+
secret: signingSecret, // returned once, when you create the subscription or rotate the secret
|
|
203
209
|
});
|
|
204
210
|
```
|
|
205
211
|
|
|
206
|
-
Both throw `WebhookSignatureVerificationError`
|
|
207
|
-
[`examples/webhook-verification.ts`](./examples/webhook-verification.ts)
|
|
208
|
-
`node:http` handler.
|
|
212
|
+
Both throw `WebhookSignatureVerificationError` when verification fails. There's a complete
|
|
213
|
+
`node:http` handler in [`examples/webhook-verification.ts`](./examples/webhook-verification.ts).
|
|
209
214
|
|
|
210
215
|
### Escape hatch
|
|
211
216
|
|
|
212
|
-
Every resource method is a thin wrapper
|
|
213
|
-
auth, retry, and timeout behavior.
|
|
214
|
-
|
|
217
|
+
Every resource method is a thin wrapper around `client.request()`, which carries the same
|
|
218
|
+
auth, retry, and timeout behavior. If this version of the SDK doesn't wrap an endpoint yet,
|
|
219
|
+
call it directly:
|
|
215
220
|
|
|
216
221
|
```ts
|
|
217
222
|
const data = await client.request<{ enabled: boolean }>({
|
|
@@ -241,9 +246,9 @@ npm run typecheck # tsc --noEmit
|
|
|
241
246
|
npm run lint # eslint
|
|
242
247
|
npm test # vitest
|
|
243
248
|
npm run build # tsup -> dist/ (ESM + CJS + .d.ts)
|
|
244
|
-
npm run ci
|
|
249
|
+
npm run ci # all of the above, in order
|
|
245
250
|
```
|
|
246
251
|
|
|
247
252
|
## License
|
|
248
253
|
|
|
249
|
-
MIT
|
|
254
|
+
MIT. See [LICENSE](./LICENSE).
|
package/dist/index.d.cts
CHANGED
|
@@ -351,8 +351,8 @@ declare class WalletResource extends APIResource {
|
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
type TokenType = "ASSET" | "YIELD_BEARING";
|
|
354
|
-
type TokenStatus = LooseUnion<"PENDING" | "ACTIVE" | "PAUSED">;
|
|
355
|
-
type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER">;
|
|
354
|
+
type TokenStatus = LooseUnion<"PENDING" | "ACTIVE" | "PAUSED" | "RETIRED">;
|
|
355
|
+
type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER" | "DEPLOY" | "REDEEM" | "SNAPSHOT">;
|
|
356
356
|
type TokenTransactionStatus = LooseUnion<"PENDING" | "CONFIRMED" | "FAILED">;
|
|
357
357
|
interface YieldParams {
|
|
358
358
|
/** Annual yield rate as a percentage, e.g. `5.5` for 5.5%. */
|
|
@@ -372,6 +372,8 @@ interface YieldParams {
|
|
|
372
372
|
callable?: boolean;
|
|
373
373
|
/** Call date, `YYYY-MM-DD`. Only meaningful when `callable` is `true`. */
|
|
374
374
|
callDate?: string;
|
|
375
|
+
/** Early redemption fee, in basis points. */
|
|
376
|
+
earlyRedemptionFee?: number;
|
|
375
377
|
}
|
|
376
378
|
interface CreateTokenParams {
|
|
377
379
|
/** Short token symbol, e.g. `"ACMB3"`. */
|
|
@@ -379,7 +381,7 @@ interface CreateTokenParams {
|
|
|
379
381
|
name: string;
|
|
380
382
|
/** Issue price per token, in fiat major units. */
|
|
381
383
|
price?: number;
|
|
382
|
-
|
|
384
|
+
chainId: string;
|
|
383
385
|
decimals: number;
|
|
384
386
|
/** Asset class, e.g. `"MONEY_MARKET"`. */
|
|
385
387
|
assetClass: string;
|
|
@@ -396,7 +398,7 @@ interface CreateTokenParams {
|
|
|
396
398
|
/** Result of a token deployment submission — `status` starts `PENDING` until the chain confirms it. */
|
|
397
399
|
interface TokenDeploymentResult {
|
|
398
400
|
id: string;
|
|
399
|
-
|
|
401
|
+
chainId: string;
|
|
400
402
|
status: TokenStatus;
|
|
401
403
|
operationRef: string;
|
|
402
404
|
tokenAdmin: string;
|
|
@@ -425,7 +427,7 @@ interface TokenSummary {
|
|
|
425
427
|
/** Per-chain deployment details within a {@link TokenDetail}. */
|
|
426
428
|
interface TokenChainDeployment {
|
|
427
429
|
id: string;
|
|
428
|
-
|
|
430
|
+
chainId: string;
|
|
429
431
|
tokenAdmin: string;
|
|
430
432
|
decimals: number;
|
|
431
433
|
status: TokenStatus;
|
|
@@ -455,7 +457,7 @@ interface ListTokensParams {
|
|
|
455
457
|
}
|
|
456
458
|
interface BurnTokenParams {
|
|
457
459
|
tokenId: string;
|
|
458
|
-
|
|
460
|
+
chainId: string;
|
|
459
461
|
/** Holder address to burn from. */
|
|
460
462
|
fromAddress: string;
|
|
461
463
|
/** Amount to burn, in token units. */
|
|
@@ -465,7 +467,7 @@ interface BurnTokenParams {
|
|
|
465
467
|
}
|
|
466
468
|
interface MintTokenParams {
|
|
467
469
|
tokenId: string;
|
|
468
|
-
|
|
470
|
+
chainId: string;
|
|
469
471
|
/** Recipient wallet address. */
|
|
470
472
|
toAddress: string;
|
|
471
473
|
/** Amount to mint, in token units. */
|
|
@@ -474,7 +476,7 @@ interface MintTokenParams {
|
|
|
474
476
|
}
|
|
475
477
|
interface TransferTokenParams {
|
|
476
478
|
tokenId: string;
|
|
477
|
-
|
|
479
|
+
chainId: string;
|
|
478
480
|
fromAddress: string;
|
|
479
481
|
toAddress: string;
|
|
480
482
|
/** Amount to transfer, in token units. */
|
|
@@ -512,17 +514,17 @@ interface TokenTransferResult {
|
|
|
512
514
|
}
|
|
513
515
|
interface RegisterTokenWalletParams {
|
|
514
516
|
tokenId: string;
|
|
515
|
-
|
|
517
|
+
chainId: string;
|
|
516
518
|
walletAddress: string;
|
|
517
519
|
}
|
|
518
520
|
interface RegisterTokenWalletResult {
|
|
519
521
|
tokenId: string;
|
|
520
|
-
|
|
522
|
+
chainId: string;
|
|
521
523
|
walletAddress: string;
|
|
522
524
|
}
|
|
523
525
|
interface GetTokenHoldersParams {
|
|
524
526
|
tokenId: string;
|
|
525
|
-
|
|
527
|
+
chainId?: string;
|
|
526
528
|
page?: number;
|
|
527
529
|
pageSize?: number;
|
|
528
530
|
}
|
|
@@ -533,14 +535,21 @@ interface TokenHolder {
|
|
|
533
535
|
}
|
|
534
536
|
interface ListTokenTransactionsParams {
|
|
535
537
|
tokenId?: string;
|
|
538
|
+
chainId?: string;
|
|
536
539
|
page?: number;
|
|
537
540
|
pageSize?: number;
|
|
541
|
+
type?: TokenTransactionType;
|
|
542
|
+
status?: TokenTransactionStatus;
|
|
543
|
+
fromAddress?: string;
|
|
544
|
+
toAddress?: string;
|
|
545
|
+
txHash?: string;
|
|
546
|
+
operationRef?: string;
|
|
538
547
|
}
|
|
539
548
|
/** A recorded on-chain operation against a token (mint, burn, or transfer). */
|
|
540
549
|
interface TokenTransactionRecord {
|
|
541
550
|
id: string;
|
|
542
551
|
tokenId: string;
|
|
543
|
-
|
|
552
|
+
chainId: string;
|
|
544
553
|
projectId?: string;
|
|
545
554
|
type: TokenTransactionType;
|
|
546
555
|
status: TokenTransactionStatus;
|
|
@@ -561,22 +570,24 @@ interface TokenTransactionRecord {
|
|
|
561
570
|
interface UpdateTokenYieldParams {
|
|
562
571
|
/** Yield-bearing token id. */
|
|
563
572
|
tokenId: string;
|
|
564
|
-
|
|
573
|
+
chainId: string;
|
|
565
574
|
/** New annual yield rate, as a percentage. */
|
|
566
575
|
annualRate: number;
|
|
567
576
|
}
|
|
568
577
|
interface DistributeYieldParams {
|
|
569
578
|
tokenId: string;
|
|
570
|
-
|
|
579
|
+
chainId: string;
|
|
571
580
|
/** Amount to fund the distribution, in fiat major units. */
|
|
572
581
|
fundAmount: number;
|
|
582
|
+
payoutToken?: string;
|
|
573
583
|
/** Seconds after which unclaimed funds may be reclaimed. */
|
|
574
584
|
reclaimAfter?: number;
|
|
575
585
|
memo?: string;
|
|
576
586
|
}
|
|
577
587
|
interface PayCouponParams {
|
|
578
588
|
tokenId: string;
|
|
579
|
-
|
|
589
|
+
chainId: string;
|
|
590
|
+
payoutToken?: string;
|
|
580
591
|
/** Push the coupon to investors instead of letting them claim it. */
|
|
581
592
|
pushYield?: boolean;
|
|
582
593
|
reclaimAfter?: number;
|
|
@@ -584,7 +595,7 @@ interface PayCouponParams {
|
|
|
584
595
|
}
|
|
585
596
|
interface ClaimYieldParams {
|
|
586
597
|
tokenId: string;
|
|
587
|
-
|
|
598
|
+
chainId: string;
|
|
588
599
|
/** HD address index of the claiming investor. */
|
|
589
600
|
investorAddressIndex: number;
|
|
590
601
|
/** Distribution snapshot to claim against. */
|
|
@@ -592,7 +603,7 @@ interface ClaimYieldParams {
|
|
|
592
603
|
}
|
|
593
604
|
interface RedeemPrincipalParams {
|
|
594
605
|
tokenId: string;
|
|
595
|
-
|
|
606
|
+
chainId: string;
|
|
596
607
|
/** Push redeemed funds to investors instead of letting them claim. */
|
|
597
608
|
pushYield?: boolean;
|
|
598
609
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -351,8 +351,8 @@ declare class WalletResource extends APIResource {
|
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
type TokenType = "ASSET" | "YIELD_BEARING";
|
|
354
|
-
type TokenStatus = LooseUnion<"PENDING" | "ACTIVE" | "PAUSED">;
|
|
355
|
-
type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER">;
|
|
354
|
+
type TokenStatus = LooseUnion<"PENDING" | "ACTIVE" | "PAUSED" | "RETIRED">;
|
|
355
|
+
type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER" | "DEPLOY" | "REDEEM" | "SNAPSHOT">;
|
|
356
356
|
type TokenTransactionStatus = LooseUnion<"PENDING" | "CONFIRMED" | "FAILED">;
|
|
357
357
|
interface YieldParams {
|
|
358
358
|
/** Annual yield rate as a percentage, e.g. `5.5` for 5.5%. */
|
|
@@ -372,6 +372,8 @@ interface YieldParams {
|
|
|
372
372
|
callable?: boolean;
|
|
373
373
|
/** Call date, `YYYY-MM-DD`. Only meaningful when `callable` is `true`. */
|
|
374
374
|
callDate?: string;
|
|
375
|
+
/** Early redemption fee, in basis points. */
|
|
376
|
+
earlyRedemptionFee?: number;
|
|
375
377
|
}
|
|
376
378
|
interface CreateTokenParams {
|
|
377
379
|
/** Short token symbol, e.g. `"ACMB3"`. */
|
|
@@ -379,7 +381,7 @@ interface CreateTokenParams {
|
|
|
379
381
|
name: string;
|
|
380
382
|
/** Issue price per token, in fiat major units. */
|
|
381
383
|
price?: number;
|
|
382
|
-
|
|
384
|
+
chainId: string;
|
|
383
385
|
decimals: number;
|
|
384
386
|
/** Asset class, e.g. `"MONEY_MARKET"`. */
|
|
385
387
|
assetClass: string;
|
|
@@ -396,7 +398,7 @@ interface CreateTokenParams {
|
|
|
396
398
|
/** Result of a token deployment submission — `status` starts `PENDING` until the chain confirms it. */
|
|
397
399
|
interface TokenDeploymentResult {
|
|
398
400
|
id: string;
|
|
399
|
-
|
|
401
|
+
chainId: string;
|
|
400
402
|
status: TokenStatus;
|
|
401
403
|
operationRef: string;
|
|
402
404
|
tokenAdmin: string;
|
|
@@ -425,7 +427,7 @@ interface TokenSummary {
|
|
|
425
427
|
/** Per-chain deployment details within a {@link TokenDetail}. */
|
|
426
428
|
interface TokenChainDeployment {
|
|
427
429
|
id: string;
|
|
428
|
-
|
|
430
|
+
chainId: string;
|
|
429
431
|
tokenAdmin: string;
|
|
430
432
|
decimals: number;
|
|
431
433
|
status: TokenStatus;
|
|
@@ -455,7 +457,7 @@ interface ListTokensParams {
|
|
|
455
457
|
}
|
|
456
458
|
interface BurnTokenParams {
|
|
457
459
|
tokenId: string;
|
|
458
|
-
|
|
460
|
+
chainId: string;
|
|
459
461
|
/** Holder address to burn from. */
|
|
460
462
|
fromAddress: string;
|
|
461
463
|
/** Amount to burn, in token units. */
|
|
@@ -465,7 +467,7 @@ interface BurnTokenParams {
|
|
|
465
467
|
}
|
|
466
468
|
interface MintTokenParams {
|
|
467
469
|
tokenId: string;
|
|
468
|
-
|
|
470
|
+
chainId: string;
|
|
469
471
|
/** Recipient wallet address. */
|
|
470
472
|
toAddress: string;
|
|
471
473
|
/** Amount to mint, in token units. */
|
|
@@ -474,7 +476,7 @@ interface MintTokenParams {
|
|
|
474
476
|
}
|
|
475
477
|
interface TransferTokenParams {
|
|
476
478
|
tokenId: string;
|
|
477
|
-
|
|
479
|
+
chainId: string;
|
|
478
480
|
fromAddress: string;
|
|
479
481
|
toAddress: string;
|
|
480
482
|
/** Amount to transfer, in token units. */
|
|
@@ -512,17 +514,17 @@ interface TokenTransferResult {
|
|
|
512
514
|
}
|
|
513
515
|
interface RegisterTokenWalletParams {
|
|
514
516
|
tokenId: string;
|
|
515
|
-
|
|
517
|
+
chainId: string;
|
|
516
518
|
walletAddress: string;
|
|
517
519
|
}
|
|
518
520
|
interface RegisterTokenWalletResult {
|
|
519
521
|
tokenId: string;
|
|
520
|
-
|
|
522
|
+
chainId: string;
|
|
521
523
|
walletAddress: string;
|
|
522
524
|
}
|
|
523
525
|
interface GetTokenHoldersParams {
|
|
524
526
|
tokenId: string;
|
|
525
|
-
|
|
527
|
+
chainId?: string;
|
|
526
528
|
page?: number;
|
|
527
529
|
pageSize?: number;
|
|
528
530
|
}
|
|
@@ -533,14 +535,21 @@ interface TokenHolder {
|
|
|
533
535
|
}
|
|
534
536
|
interface ListTokenTransactionsParams {
|
|
535
537
|
tokenId?: string;
|
|
538
|
+
chainId?: string;
|
|
536
539
|
page?: number;
|
|
537
540
|
pageSize?: number;
|
|
541
|
+
type?: TokenTransactionType;
|
|
542
|
+
status?: TokenTransactionStatus;
|
|
543
|
+
fromAddress?: string;
|
|
544
|
+
toAddress?: string;
|
|
545
|
+
txHash?: string;
|
|
546
|
+
operationRef?: string;
|
|
538
547
|
}
|
|
539
548
|
/** A recorded on-chain operation against a token (mint, burn, or transfer). */
|
|
540
549
|
interface TokenTransactionRecord {
|
|
541
550
|
id: string;
|
|
542
551
|
tokenId: string;
|
|
543
|
-
|
|
552
|
+
chainId: string;
|
|
544
553
|
projectId?: string;
|
|
545
554
|
type: TokenTransactionType;
|
|
546
555
|
status: TokenTransactionStatus;
|
|
@@ -561,22 +570,24 @@ interface TokenTransactionRecord {
|
|
|
561
570
|
interface UpdateTokenYieldParams {
|
|
562
571
|
/** Yield-bearing token id. */
|
|
563
572
|
tokenId: string;
|
|
564
|
-
|
|
573
|
+
chainId: string;
|
|
565
574
|
/** New annual yield rate, as a percentage. */
|
|
566
575
|
annualRate: number;
|
|
567
576
|
}
|
|
568
577
|
interface DistributeYieldParams {
|
|
569
578
|
tokenId: string;
|
|
570
|
-
|
|
579
|
+
chainId: string;
|
|
571
580
|
/** Amount to fund the distribution, in fiat major units. */
|
|
572
581
|
fundAmount: number;
|
|
582
|
+
payoutToken?: string;
|
|
573
583
|
/** Seconds after which unclaimed funds may be reclaimed. */
|
|
574
584
|
reclaimAfter?: number;
|
|
575
585
|
memo?: string;
|
|
576
586
|
}
|
|
577
587
|
interface PayCouponParams {
|
|
578
588
|
tokenId: string;
|
|
579
|
-
|
|
589
|
+
chainId: string;
|
|
590
|
+
payoutToken?: string;
|
|
580
591
|
/** Push the coupon to investors instead of letting them claim it. */
|
|
581
592
|
pushYield?: boolean;
|
|
582
593
|
reclaimAfter?: number;
|
|
@@ -584,7 +595,7 @@ interface PayCouponParams {
|
|
|
584
595
|
}
|
|
585
596
|
interface ClaimYieldParams {
|
|
586
597
|
tokenId: string;
|
|
587
|
-
|
|
598
|
+
chainId: string;
|
|
588
599
|
/** HD address index of the claiming investor. */
|
|
589
600
|
investorAddressIndex: number;
|
|
590
601
|
/** Distribution snapshot to claim against. */
|
|
@@ -592,7 +603,7 @@ interface ClaimYieldParams {
|
|
|
592
603
|
}
|
|
593
604
|
interface RedeemPrincipalParams {
|
|
594
605
|
tokenId: string;
|
|
595
|
-
|
|
606
|
+
chainId: string;
|
|
596
607
|
/** Push redeemed funds to investors instead of letting them claim. */
|
|
597
608
|
pushYield?: boolean;
|
|
598
609
|
}
|
package/package.json
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "infra-sdk-typescript",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Official TypeScript SDK for the Convexity Infra API — Wallet, Tokenization, and Blockchain Events (Indexer).",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Convexity",
|
|
7
|
-
"homepage": "https://docs.withconvexity.com",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/ConvexityTeam/infra-sdk-typescript.git"
|
|
11
|
-
},
|
|
12
|
-
"keywords": [
|
|
13
|
-
"convexity",
|
|
14
|
-
"wallet",
|
|
15
|
-
"tokenization",
|
|
16
|
-
"indexer",
|
|
17
|
-
"blockchain",
|
|
18
|
-
"sdk",
|
|
19
|
-
"typescript",
|
|
20
|
-
"web3"
|
|
21
|
-
],
|
|
22
|
-
"type": "module",
|
|
23
|
-
"sideEffects": false,
|
|
24
|
-
"main": "./dist/index.cjs",
|
|
25
|
-
"module": "./dist/index.js",
|
|
26
|
-
"types": "./dist/index.d.ts",
|
|
27
|
-
"exports": {
|
|
28
|
-
".": {
|
|
29
|
-
"import": {
|
|
30
|
-
"types": "./dist/index.d.ts",
|
|
31
|
-
"default": "./dist/index.js"
|
|
32
|
-
},
|
|
33
|
-
"require": {
|
|
34
|
-
"types": "./dist/index.d.cts",
|
|
35
|
-
"default": "./dist/index.cjs"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"./package.json": "./package.json"
|
|
39
|
-
},
|
|
40
|
-
"files": [
|
|
41
|
-
"dist",
|
|
42
|
-
"README.md",
|
|
43
|
-
"LICENSE",
|
|
44
|
-
"CHANGELOG.md"
|
|
45
|
-
],
|
|
46
|
-
"engines": {
|
|
47
|
-
"node": ">=18"
|
|
48
|
-
},
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build": "tsup",
|
|
51
|
-
"dev": "tsup --watch",
|
|
52
|
-
"typecheck": "tsc --noEmit",
|
|
53
|
-
"lint": "eslint src tests",
|
|
54
|
-
"lint:fix": "eslint src tests --fix",
|
|
55
|
-
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\" \"examples/**/*.ts\"",
|
|
56
|
-
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\" \"examples/**/*.ts\"",
|
|
57
|
-
"test": "vitest run",
|
|
58
|
-
"test:watch": "vitest",
|
|
59
|
-
"test:coverage": "vitest run --coverage",
|
|
60
|
-
"prepublishOnly": "npm run build",
|
|
61
|
-
"ci": "npm run typecheck && npm run lint && npm run test && npm run build"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"@eslint/js": "^9.18.0",
|
|
65
|
-
"@types/node": "^20.14.0",
|
|
66
|
-
"@vitest/coverage-v8": "^2.1.8",
|
|
67
|
-
"eslint": "^9.18.0",
|
|
68
|
-
"eslint-config-prettier": "^9.1.0",
|
|
69
|
-
"prettier": "^3.4.2",
|
|
70
|
-
"tsup": "^8.3.5",
|
|
71
|
-
"typescript": "^5.7.3",
|
|
72
|
-
"typescript-eslint": "^8.19.1",
|
|
73
|
-
"vitest": "^2.1.8"
|
|
74
|
-
},
|
|
75
|
-
"publishConfig": {
|
|
76
|
-
"access": "public"
|
|
77
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "infra-sdk-typescript",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Official TypeScript SDK for the Convexity Infra API — Wallet, Tokenization, and Blockchain Events (Indexer).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Convexity",
|
|
7
|
+
"homepage": "https://docs.withconvexity.com",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/ConvexityTeam/infra-sdk-typescript.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"convexity",
|
|
14
|
+
"wallet",
|
|
15
|
+
"tokenization",
|
|
16
|
+
"indexer",
|
|
17
|
+
"blockchain",
|
|
18
|
+
"sdk",
|
|
19
|
+
"typescript",
|
|
20
|
+
"web3"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"main": "./dist/index.cjs",
|
|
25
|
+
"module": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./dist/index.d.cts",
|
|
35
|
+
"default": "./dist/index.cjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE",
|
|
44
|
+
"CHANGELOG.md"
|
|
45
|
+
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsup",
|
|
51
|
+
"dev": "tsup --watch",
|
|
52
|
+
"typecheck": "tsc --noEmit",
|
|
53
|
+
"lint": "eslint src tests",
|
|
54
|
+
"lint:fix": "eslint src tests --fix",
|
|
55
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\" \"examples/**/*.ts\"",
|
|
56
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\" \"examples/**/*.ts\"",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:watch": "vitest",
|
|
59
|
+
"test:coverage": "vitest run --coverage",
|
|
60
|
+
"prepublishOnly": "npm run build",
|
|
61
|
+
"ci": "npm run typecheck && npm run lint && npm run test && npm run build"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@eslint/js": "^9.18.0",
|
|
65
|
+
"@types/node": "^20.14.0",
|
|
66
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
67
|
+
"eslint": "^9.18.0",
|
|
68
|
+
"eslint-config-prettier": "^9.1.0",
|
|
69
|
+
"prettier": "^3.4.2",
|
|
70
|
+
"tsup": "^8.3.5",
|
|
71
|
+
"typescript": "^5.7.3",
|
|
72
|
+
"typescript-eslint": "^8.19.1",
|
|
73
|
+
"vitest": "^2.1.8"
|
|
74
|
+
},
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public"
|
|
77
|
+
}
|
|
78
78
|
}
|