Skip to content

Commit 7ca19ef

Browse files
committed
scripts: add tapd to generate_types script
1 parent 4d02025 commit 7ca19ef

File tree

12 files changed

+1523
-6
lines changed

12 files changed

+1523
-6
lines changed

lib/types/proto/assetwalletrpc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './tapd/assetwalletrpc/assetwallet';

lib/types/proto/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import * as watchtowerrpc from './watchtowerrpc';
1111
import * as wtclientrpc from './wtclientrpc';
1212
import * as looprpc from './looprpc';
1313
import * as poolrpc from './poolrpc';
14+
import * as assetwalletrpc from './assetwalletrpc';
15+
import * as mintrpc from './mintrpc';
16+
import * as taprpc from './taprpc';
17+
import * as universerpc from './universerpc';
1418
export {
1519
frdrpc,
1620
litrpc,
@@ -24,5 +28,9 @@ export {
2428
watchtowerrpc,
2529
wtclientrpc,
2630
looprpc,
27-
poolrpc
31+
poolrpc,
32+
assetwalletrpc,
33+
mintrpc,
34+
taprpc,
35+
universerpc
2836
};

lib/types/proto/mintrpc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './tapd/mintrpc/mint';

lib/types/proto/schema.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ export const serviceNames = {
2727
ChannelAuctioneer: 'poolrpc.ChannelAuctioneer',
2828
HashMail: 'poolrpc.HashMail',
2929
Trader: 'poolrpc.Trader'
30-
}
30+
},
31+
assetwalletrpc: { AssetWallet: 'assetwalletrpc.AssetWallet' },
32+
mintrpc: { Mint: 'mintrpc.Mint' },
33+
taprpc: { TaprootAssets: 'taprpc.TaprootAssets' },
34+
universerpc: { Universe: 'universerpc.Universe' }
3135
};
3236

3337
// This array contains the list of methods that are server streaming. It is
@@ -64,5 +68,6 @@ export const subscriptionMethods = [
6468
'looprpc.SwapClient.Monitor',
6569
'poolrpc.ChannelAuctioneer.SubscribeBatchAuction',
6670
'poolrpc.ChannelAuctioneer.SubscribeSidecar',
67-
'poolrpc.HashMail.RecvStream'
71+
'poolrpc.HashMail.RecvStream',
72+
'taprpc.TaprootAssets.SubscribeSendAssetEventNtfns'
6873
];
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
/* eslint-disable */
2+
import type {
3+
KeyDescriptor,
4+
ScriptKey,
5+
SendAssetResponse
6+
} from '../taprootassets';
7+
8+
export interface FundVirtualPsbtRequest {
9+
/**
10+
* Use an existing PSBT packet as the template for the funded PSBT.
11+
*
12+
* TODO(guggero): Actually implement this. We can't use the "reserved"
13+
* keyword here because we're in a oneof, so we add the field but implement
14+
* it later.
15+
*/
16+
psbt: Uint8Array | string | undefined;
17+
/** Use the asset outputs and optional asset inputs from this raw template. */
18+
raw: TxTemplate | undefined;
19+
}
20+
21+
export interface FundVirtualPsbtResponse {
22+
/** The funded but not yet signed PSBT packet. */
23+
fundedPsbt: Uint8Array | string;
24+
/** The index of the added change output or -1 if no change was left over. */
25+
changeOutputIndex: number;
26+
}
27+
28+
export interface TxTemplate {
29+
/**
30+
* An optional list of inputs to use. Every input must be an asset UTXO known
31+
* to the wallet. The sum of all inputs must be greater than or equal to the
32+
* sum of all outputs.
33+
*
34+
* If no inputs are specified, asset coin selection will be performed instead
35+
* and inputs of sufficient value will be added to the resulting PSBT.
36+
*/
37+
inputs: PrevId[];
38+
/**
39+
* A map of all Taproot Asset addresses mapped to the anchor transaction's
40+
* output index that should be sent to.
41+
*/
42+
recipients: { [key: string]: string };
43+
}
44+
45+
export interface TxTemplate_RecipientsEntry {
46+
key: string;
47+
value: string;
48+
}
49+
50+
export interface PrevId {
51+
/** The bitcoin anchor output on chain that contains the input asset. */
52+
outpoint: OutPoint | undefined;
53+
/** The asset ID of the previous asset tree. */
54+
id: Uint8Array | string;
55+
/**
56+
* The tweaked Taproot output key committing to the possible spending
57+
* conditions of the asset.
58+
*/
59+
scriptKey: Uint8Array | string;
60+
}
61+
62+
export interface OutPoint {
63+
/** Raw bytes representing the transaction id. */
64+
txid: Uint8Array | string;
65+
/** The index of the output on the transaction. */
66+
outputIndex: number;
67+
}
68+
69+
export interface SignVirtualPsbtRequest {
70+
/**
71+
* The PSBT of the virtual transaction that should be signed. The PSBT must
72+
* contain all required inputs, outputs, UTXO data and custom fields required
73+
* to identify the signing key.
74+
*/
75+
fundedPsbt: Uint8Array | string;
76+
}
77+
78+
export interface SignVirtualPsbtResponse {
79+
/** The signed virtual transaction in PSBT format. */
80+
signedPsbt: Uint8Array | string;
81+
/** The indices of signed inputs. */
82+
signedInputs: number[];
83+
}
84+
85+
export interface AnchorVirtualPsbtsRequest {
86+
/**
87+
* The list of virtual transactions that should be merged and committed to in
88+
* the BTC level anchor transaction.
89+
*/
90+
virtualPsbts: Uint8Array | string[];
91+
}
92+
93+
export interface NextInternalKeyRequest {
94+
keyFamily: number;
95+
}
96+
97+
export interface NextInternalKeyResponse {
98+
internalKey: KeyDescriptor | undefined;
99+
}
100+
101+
export interface NextScriptKeyRequest {
102+
keyFamily: number;
103+
}
104+
105+
export interface NextScriptKeyResponse {
106+
scriptKey: ScriptKey | undefined;
107+
}
108+
109+
export interface ProveAssetOwnershipRequest {
110+
assetId: Uint8Array | string;
111+
scriptKey: Uint8Array | string;
112+
}
113+
114+
export interface ProveAssetOwnershipResponse {
115+
proofWithWitness: Uint8Array | string;
116+
}
117+
118+
export interface VerifyAssetOwnershipRequest {
119+
proofWithWitness: Uint8Array | string;
120+
}
121+
122+
export interface VerifyAssetOwnershipResponse {
123+
validProof: boolean;
124+
}
125+
126+
export interface AssetWallet {
127+
/**
128+
* FundVirtualPsbt selects inputs from the available asset commitments to fund
129+
* a virtual transaction matching the template.
130+
*/
131+
fundVirtualPsbt(
132+
request?: DeepPartial<FundVirtualPsbtRequest>
133+
): Promise<FundVirtualPsbtResponse>;
134+
/**
135+
* SignVirtualPsbt signs the inputs of a virtual transaction and prepares the
136+
* commitments of the inputs and outputs.
137+
*/
138+
signVirtualPsbt(
139+
request?: DeepPartial<SignVirtualPsbtRequest>
140+
): Promise<SignVirtualPsbtResponse>;
141+
/**
142+
* AnchorVirtualPsbts merges and then commits multiple virtual transactions in
143+
* a single BTC level anchor transaction.
144+
*
145+
* TODO(guggero): Actually implement accepting and merging multiple
146+
* transactions.
147+
*/
148+
anchorVirtualPsbts(
149+
request?: DeepPartial<AnchorVirtualPsbtsRequest>
150+
): Promise<SendAssetResponse>;
151+
/**
152+
* NextInternalKey derives the next internal key for the given key family and
153+
* stores it as an internal key in the database to make sure it is identified
154+
* as a local key later on when importing proofs. While an internal key can
155+
* also be used as the internal key of a script key, it is recommended to use
156+
* the NextScriptKey RPC instead, to make sure the tweaked Taproot output key
157+
* is also recognized as a local key.
158+
*/
159+
nextInternalKey(
160+
request?: DeepPartial<NextInternalKeyRequest>
161+
): Promise<NextInternalKeyResponse>;
162+
/**
163+
* NextScriptKey derives the next script key (and its corresponding internal
164+
* key) and stores them both in the database to make sure they are identified
165+
* as local keys later on when importing proofs.
166+
*/
167+
nextScriptKey(
168+
request?: DeepPartial<NextScriptKeyRequest>
169+
): Promise<NextScriptKeyResponse>;
170+
/**
171+
* ProveAssetOwnership creates an ownership proof embedded in an asset
172+
* transition proof. That ownership proof is a signed virtual transaction
173+
* spending the asset with a valid witness to prove the prover owns the keys
174+
* that can spend the asset.
175+
*/
176+
proveAssetOwnership(
177+
request?: DeepPartial<ProveAssetOwnershipRequest>
178+
): Promise<ProveAssetOwnershipResponse>;
179+
/**
180+
* VerifyAssetOwnership verifies the asset ownership proof embedded in the
181+
* given transition proof of an asset and returns true if the proof is valid.
182+
*/
183+
verifyAssetOwnership(
184+
request?: DeepPartial<VerifyAssetOwnershipRequest>
185+
): Promise<VerifyAssetOwnershipResponse>;
186+
}
187+
188+
type Builtin =
189+
| Date
190+
| Function
191+
| Uint8Array
192+
| string
193+
| number
194+
| boolean
195+
| undefined;
196+
197+
type DeepPartial<T> = T extends Builtin
198+
? T
199+
: T extends Array<infer U>
200+
? Array<DeepPartial<U>>
201+
: T extends ReadonlyArray<infer U>
202+
? ReadonlyArray<DeepPartial<U>>
203+
: T extends {}
204+
? { [K in keyof T]?: DeepPartial<T[K]> }
205+
: Partial<T>;
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/* eslint-disable */
2+
import type { AssetType, AssetMeta } from '../taprootassets';
3+
4+
export enum BatchState {
5+
BATCH_STATE_UNKNOWN = 'BATCH_STATE_UNKNOWN',
6+
BATCH_STATE_PEDNING = 'BATCH_STATE_PEDNING',
7+
BATCH_STATE_FROZEN = 'BATCH_STATE_FROZEN',
8+
BATCH_STATE_COMMITTED = 'BATCH_STATE_COMMITTED',
9+
BATCH_STATE_BROADCAST = 'BATCH_STATE_BROADCAST',
10+
BATCH_STATE_CONFIRMED = 'BATCH_STATE_CONFIRMED',
11+
BATCH_STATE_FINALIZED = 'BATCH_STATE_FINALIZED',
12+
BATCH_STATE_SEEDLING_CANCELLED = 'BATCH_STATE_SEEDLING_CANCELLED',
13+
BATCH_STATE_SPROUT_CANCELLED = 'BATCH_STATE_SPROUT_CANCELLED',
14+
UNRECOGNIZED = 'UNRECOGNIZED'
15+
}
16+
17+
export interface MintAsset {
18+
/** The type of the asset to be created. */
19+
assetType: AssetType;
20+
/** The name, or "tag" of the asset. This will affect the final asset ID. */
21+
name: string;
22+
/**
23+
* A blob that resents metadata related to the asset. This will affect the
24+
* final asset ID.
25+
*/
26+
assetMeta: AssetMeta | undefined;
27+
/**
28+
* The total amount of units of the new asset that should be created. If the
29+
* AssetType is Collectible, then this field cannot be set.
30+
*/
31+
amount: string;
32+
/** The specific group key this asset should be minted with. */
33+
groupKey: Uint8Array | string;
34+
/**
35+
* The name of the asset in the batch that will anchor a new asset group.
36+
* This asset will be minted with the same group key as the anchor asset.
37+
*/
38+
groupAnchor: string;
39+
}
40+
41+
export interface MintAssetRequest {
42+
/** The asset to be minted. */
43+
asset: MintAsset | undefined;
44+
/**
45+
* If true, then the asset will be created with a group key, which allows for
46+
* future asset issuance.
47+
*/
48+
enableEmission: boolean;
49+
}
50+
51+
export interface MintAssetResponse {
52+
/**
53+
* A public key serialized in compressed format that can be used to uniquely
54+
* identify a pending minting batch. Responses that share the same key will be
55+
* batched into the same minting transaction.
56+
*/
57+
batchKey: Uint8Array | string;
58+
}
59+
60+
export interface MintingBatch {
61+
/** The internal public key of the batch. */
62+
batchKey: Uint8Array | string;
63+
/** The assets that are part of the batch. */
64+
assets: MintAsset[];
65+
/** The state of the batch. */
66+
state: BatchState;
67+
}
68+
69+
export interface FinalizeBatchRequest {}
70+
71+
export interface FinalizeBatchResponse {
72+
/** The internal public key of the batch. */
73+
batchKey: Uint8Array | string;
74+
}
75+
76+
export interface CancelBatchRequest {}
77+
78+
export interface CancelBatchResponse {
79+
/** The internal public key of the batch. */
80+
batchKey: Uint8Array | string;
81+
}
82+
83+
export interface ListBatchRequest {
84+
/**
85+
* The optional batch key of the batch to list. When using REST this field
86+
* must be encoded as base64url.
87+
*/
88+
batchKey: Uint8Array | string;
89+
}
90+
91+
export interface ListBatchResponse {
92+
batches: MintingBatch[];
93+
}
94+
95+
export interface Mint {
96+
/**
97+
* tapcli: `assets mint`
98+
* MintAsset will attempt to mint the set of assets (async by default to
99+
* ensure proper batching) specified in the request.
100+
*/
101+
mintAsset(
102+
request?: DeepPartial<MintAssetRequest>
103+
): Promise<MintAssetResponse>;
104+
/**
105+
* tapcli: `assets mint finalize`
106+
* FinalizeBatch will attempt to finalize the current pending batch.
107+
*/
108+
finalizeBatch(
109+
request?: DeepPartial<FinalizeBatchRequest>
110+
): Promise<FinalizeBatchResponse>;
111+
/**
112+
* tapcli: `assets mint cancel`
113+
* CancelBatch will attempt to cancel the current pending batch.
114+
*/
115+
cancelBatch(
116+
request?: DeepPartial<CancelBatchRequest>
117+
): Promise<CancelBatchResponse>;
118+
/**
119+
* tapcli: `assets mint batches`
120+
* ListBatches lists the set of batches submitted to the daemon, including
121+
* pending and cancelled batches.
122+
*/
123+
listBatches(
124+
request?: DeepPartial<ListBatchRequest>
125+
): Promise<ListBatchResponse>;
126+
}
127+
128+
type Builtin =
129+
| Date
130+
| Function
131+
| Uint8Array
132+
| string
133+
| number
134+
| boolean
135+
| undefined;
136+
137+
type DeepPartial<T> = T extends Builtin
138+
? T
139+
: T extends Array<infer U>
140+
? Array<DeepPartial<U>>
141+
: T extends ReadonlyArray<infer U>
142+
? ReadonlyArray<DeepPartial<U>>
143+
: T extends {}
144+
? { [K in keyof T]?: DeepPartial<T[K]> }
145+
: Partial<T>;

0 commit comments

Comments
 (0)