@hazbase/simplicity 0.0.4 → 0.0.5

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.
@@ -1,10 +1,10 @@
1
1
  import { ElementsRpcClient } from "../core/rpc";
2
- import { BondDefinition, BondIssuanceState, DefinitionInput, DefinitionVerificationResult, CompileFromFileInput, CompileFromPresetInput, DefinitionDescriptor, StateDocumentDescriptor, StateDocumentInput, StateVerificationResult, SimplicityArtifact, SimplicityClientConfig } from "../core/types";
2
+ import { BondDefinition, BondIssuanceState, BondSettlementDescriptor, DefinitionInput, DefinitionVerificationResult, CompileFromFileInput, CompileFromPresetInput, DefinitionDescriptor, StateDocumentDescriptor, StateDocumentInput, StateVerificationResult, SimplicityArtifact, SimplicityClientConfig } from "../core/types";
3
3
  import { RelayerClient } from "../gasless/RelayerClient";
4
4
  import { GaslessTransferInput, GaslessTransferResult, RelayerClientConfig } from "../gasless/types";
5
5
  import { CompiledContract } from "./ContractFactory";
6
6
  import { DeployedContract } from "./DeployedContract";
7
- import { loadBond, verifyBond } from "../domain/bond";
7
+ import { buildBondPayload, buildBondRedemption, buildBondTransitionPayload, buildBondRolloverPlan, buildBondMachineRolloverPlan, buildBondMachineSettlementPlan, buildBondSettlementDescriptor, buildBondSettlementPayload, compileBondRedemptionMachine, compileBondTransition, executeBondStateRollover, executeBondMachineRollover, executeBondMachineSettlement, inspectBondStateRollover, inspectBondMachineRollover, inspectBondMachineSettlement, loadBond, redeemBond, verifyBond, verifyBondSettlementDescriptor, verifyBondRedemptionMachineArtifact, verifyBondTransition } from "../domain/bond";
8
8
  export declare class SimplicityClient {
9
9
  readonly config: SimplicityClientConfig;
10
10
  readonly rpc: ElementsRpcClient;
@@ -28,6 +28,271 @@ export declare class SimplicityClient {
28
28
  issuancePath?: string;
29
29
  issuanceValue?: BondIssuanceState;
30
30
  }) => ReturnType<typeof verifyBond>;
31
+ redeemBond: (input: {
32
+ definitionPath?: string;
33
+ definitionValue?: BondDefinition;
34
+ previousIssuancePath?: string;
35
+ previousIssuanceValue?: BondIssuanceState;
36
+ amount: number;
37
+ redeemedAt: string;
38
+ simfPath?: string;
39
+ artifactPath?: string;
40
+ }) => ReturnType<typeof redeemBond>;
41
+ verifyBondTransition: (input: {
42
+ previousIssuancePath?: string;
43
+ previousIssuanceValue?: BondIssuanceState;
44
+ nextIssuancePath?: string;
45
+ nextIssuanceValue?: BondIssuanceState;
46
+ }) => ReturnType<typeof verifyBondTransition>;
47
+ buildBondRedemption: (input: {
48
+ definitionPath?: string;
49
+ definitionValue?: BondDefinition;
50
+ previousIssuancePath?: string;
51
+ previousIssuanceValue?: BondIssuanceState;
52
+ amount: number;
53
+ redeemedAt: string;
54
+ }) => ReturnType<typeof buildBondRedemption>;
55
+ buildBondPayload: (input: {
56
+ artifactPath?: string;
57
+ artifact?: SimplicityArtifact;
58
+ definitionPath?: string;
59
+ definitionValue?: BondDefinition;
60
+ issuancePath?: string;
61
+ issuanceValue?: BondIssuanceState;
62
+ }) => ReturnType<typeof buildBondPayload>;
63
+ buildBondTransitionPayload: (input: {
64
+ definitionPath?: string;
65
+ definitionValue?: BondDefinition;
66
+ previousIssuancePath?: string;
67
+ previousIssuanceValue?: BondIssuanceState;
68
+ nextIssuancePath?: string;
69
+ nextIssuanceValue?: BondIssuanceState;
70
+ }) => ReturnType<typeof buildBondTransitionPayload>;
71
+ buildBondSettlementDescriptor: (input: {
72
+ definitionPath?: string;
73
+ definitionValue?: BondDefinition;
74
+ previousIssuancePath?: string;
75
+ previousIssuanceValue?: BondIssuanceState;
76
+ nextIssuancePath?: string;
77
+ nextIssuanceValue?: BondIssuanceState;
78
+ nextStateSimfPath?: string;
79
+ nextAmountSat: number;
80
+ maxFeeSat?: number;
81
+ }) => ReturnType<typeof buildBondSettlementDescriptor>;
82
+ verifyBondSettlementDescriptor: (input: {
83
+ descriptorPath?: string;
84
+ descriptorValue?: BondSettlementDescriptor;
85
+ definitionPath?: string;
86
+ definitionValue?: BondDefinition;
87
+ previousIssuancePath?: string;
88
+ previousIssuanceValue?: BondIssuanceState;
89
+ nextIssuancePath?: string;
90
+ nextIssuanceValue?: BondIssuanceState;
91
+ nextStateSimfPath?: string;
92
+ nextAmountSat?: number;
93
+ maxFeeSat?: number;
94
+ }) => ReturnType<typeof verifyBondSettlementDescriptor>;
95
+ buildBondSettlementPayload: (input: {
96
+ definitionPath?: string;
97
+ definitionValue?: BondDefinition;
98
+ previousIssuancePath?: string;
99
+ previousIssuanceValue?: BondIssuanceState;
100
+ nextIssuancePath?: string;
101
+ nextIssuanceValue?: BondIssuanceState;
102
+ nextStateSimfPath?: string;
103
+ nextAmountSat: number;
104
+ maxFeeSat?: number;
105
+ }) => ReturnType<typeof buildBondSettlementPayload>;
106
+ buildBondRolloverPlan: (input: {
107
+ currentArtifactPath?: string;
108
+ currentArtifact?: SimplicityArtifact;
109
+ definitionPath?: string;
110
+ definitionValue?: BondDefinition;
111
+ previousIssuancePath?: string;
112
+ previousIssuanceValue?: BondIssuanceState;
113
+ nextIssuancePath?: string;
114
+ nextIssuanceValue?: BondIssuanceState;
115
+ nextSimfPath?: string;
116
+ nextArtifactPath?: string;
117
+ }) => ReturnType<typeof buildBondRolloverPlan>;
118
+ buildBondMachineRolloverPlan: (input: {
119
+ currentArtifactPath?: string;
120
+ currentArtifact?: SimplicityArtifact;
121
+ definitionPath?: string;
122
+ definitionValue?: BondDefinition;
123
+ previousIssuancePath?: string;
124
+ previousIssuanceValue?: BondIssuanceState;
125
+ nextIssuancePath?: string;
126
+ nextIssuanceValue?: BondIssuanceState;
127
+ nextStateSimfPath?: string;
128
+ machineSimfPath?: string;
129
+ machineArtifactPath?: string;
130
+ }) => ReturnType<typeof buildBondMachineRolloverPlan>;
131
+ buildBondMachineSettlementPlan: (input: {
132
+ currentMachineArtifactPath?: string;
133
+ currentMachineArtifact?: SimplicityArtifact;
134
+ definitionPath?: string;
135
+ definitionValue?: BondDefinition;
136
+ previousIssuancePath?: string;
137
+ previousIssuanceValue?: BondIssuanceState;
138
+ nextIssuancePath?: string;
139
+ nextIssuanceValue?: BondIssuanceState;
140
+ nextSimfPath?: string;
141
+ nextArtifactPath?: string;
142
+ }) => ReturnType<typeof buildBondMachineSettlementPlan>;
143
+ compileBondTransition: (input: {
144
+ definitionPath?: string;
145
+ definitionValue?: BondDefinition;
146
+ previousIssuancePath?: string;
147
+ previousIssuanceValue?: BondIssuanceState;
148
+ nextIssuancePath?: string;
149
+ nextIssuanceValue?: BondIssuanceState;
150
+ simfPath?: string;
151
+ artifactPath?: string;
152
+ }) => ReturnType<typeof compileBondTransition>;
153
+ compileBondRedemptionMachine: (input: {
154
+ definitionPath?: string;
155
+ definitionValue?: BondDefinition;
156
+ previousIssuancePath?: string;
157
+ previousIssuanceValue?: BondIssuanceState;
158
+ nextIssuancePath?: string;
159
+ nextIssuanceValue?: BondIssuanceState;
160
+ nextStateSimfPath?: string;
161
+ nextAmountSat?: number;
162
+ maxFeeSat?: number;
163
+ simfPath?: string;
164
+ artifactPath?: string;
165
+ }) => ReturnType<typeof compileBondRedemptionMachine>;
166
+ verifyBondRedemptionMachineArtifact: (input: {
167
+ artifactPath?: string;
168
+ artifact?: SimplicityArtifact;
169
+ definitionPath?: string;
170
+ definitionValue?: BondDefinition;
171
+ previousIssuancePath?: string;
172
+ previousIssuanceValue?: BondIssuanceState;
173
+ nextIssuancePath?: string;
174
+ nextIssuanceValue?: BondIssuanceState;
175
+ nextStateSimfPath?: string;
176
+ nextAmountSat?: number;
177
+ maxFeeSat?: number;
178
+ }) => ReturnType<typeof verifyBondRedemptionMachineArtifact>;
179
+ inspectBondStateRollover: (input: {
180
+ currentArtifactPath?: string;
181
+ currentArtifact?: SimplicityArtifact;
182
+ definitionPath?: string;
183
+ definitionValue?: BondDefinition;
184
+ previousIssuancePath?: string;
185
+ previousIssuanceValue?: BondIssuanceState;
186
+ nextIssuancePath?: string;
187
+ nextIssuanceValue?: BondIssuanceState;
188
+ nextSimfPath?: string;
189
+ nextArtifactPath?: string;
190
+ wallet: string;
191
+ signer: {
192
+ type: "schnorrPrivkeyHex";
193
+ privkeyHex: string;
194
+ };
195
+ feeSat?: number;
196
+ utxoPolicy?: "smallest_over" | "largest" | "newest";
197
+ }) => ReturnType<typeof inspectBondStateRollover>;
198
+ inspectBondMachineRollover: (input: {
199
+ currentArtifactPath?: string;
200
+ currentArtifact?: SimplicityArtifact;
201
+ definitionPath?: string;
202
+ definitionValue?: BondDefinition;
203
+ previousIssuancePath?: string;
204
+ previousIssuanceValue?: BondIssuanceState;
205
+ nextIssuancePath?: string;
206
+ nextIssuanceValue?: BondIssuanceState;
207
+ machineSimfPath?: string;
208
+ machineArtifactPath?: string;
209
+ wallet: string;
210
+ signer: {
211
+ type: "schnorrPrivkeyHex";
212
+ privkeyHex: string;
213
+ };
214
+ feeSat?: number;
215
+ utxoPolicy?: "smallest_over" | "largest" | "newest";
216
+ }) => ReturnType<typeof inspectBondMachineRollover>;
217
+ inspectBondMachineSettlement: (input: {
218
+ currentMachineArtifactPath?: string;
219
+ currentMachineArtifact?: SimplicityArtifact;
220
+ definitionPath?: string;
221
+ definitionValue?: BondDefinition;
222
+ previousIssuancePath?: string;
223
+ previousIssuanceValue?: BondIssuanceState;
224
+ nextIssuancePath?: string;
225
+ nextIssuanceValue?: BondIssuanceState;
226
+ nextSimfPath?: string;
227
+ nextArtifactPath?: string;
228
+ wallet: string;
229
+ signer: {
230
+ type: "schnorrPrivkeyHex";
231
+ privkeyHex: string;
232
+ };
233
+ feeSat?: number;
234
+ utxoPolicy?: "smallest_over" | "largest" | "newest";
235
+ }) => ReturnType<typeof inspectBondMachineSettlement>;
236
+ executeBondStateRollover: (input: {
237
+ currentArtifactPath?: string;
238
+ currentArtifact?: SimplicityArtifact;
239
+ definitionPath?: string;
240
+ definitionValue?: BondDefinition;
241
+ previousIssuancePath?: string;
242
+ previousIssuanceValue?: BondIssuanceState;
243
+ nextIssuancePath?: string;
244
+ nextIssuanceValue?: BondIssuanceState;
245
+ nextSimfPath?: string;
246
+ nextArtifactPath?: string;
247
+ wallet: string;
248
+ signer: {
249
+ type: "schnorrPrivkeyHex";
250
+ privkeyHex: string;
251
+ };
252
+ feeSat?: number;
253
+ utxoPolicy?: "smallest_over" | "largest" | "newest";
254
+ broadcast?: boolean;
255
+ }) => ReturnType<typeof executeBondStateRollover>;
256
+ executeBondMachineRollover: (input: {
257
+ currentArtifactPath?: string;
258
+ currentArtifact?: SimplicityArtifact;
259
+ definitionPath?: string;
260
+ definitionValue?: BondDefinition;
261
+ previousIssuancePath?: string;
262
+ previousIssuanceValue?: BondIssuanceState;
263
+ nextIssuancePath?: string;
264
+ nextIssuanceValue?: BondIssuanceState;
265
+ machineSimfPath?: string;
266
+ machineArtifactPath?: string;
267
+ wallet: string;
268
+ signer: {
269
+ type: "schnorrPrivkeyHex";
270
+ privkeyHex: string;
271
+ };
272
+ feeSat?: number;
273
+ utxoPolicy?: "smallest_over" | "largest" | "newest";
274
+ broadcast?: boolean;
275
+ }) => ReturnType<typeof executeBondMachineRollover>;
276
+ executeBondMachineSettlement: (input: {
277
+ currentMachineArtifactPath?: string;
278
+ currentMachineArtifact?: SimplicityArtifact;
279
+ definitionPath?: string;
280
+ definitionValue?: BondDefinition;
281
+ previousIssuancePath?: string;
282
+ previousIssuanceValue?: BondIssuanceState;
283
+ nextIssuancePath?: string;
284
+ nextIssuanceValue?: BondIssuanceState;
285
+ nextSimfPath?: string;
286
+ nextArtifactPath?: string;
287
+ wallet: string;
288
+ signer: {
289
+ type: "schnorrPrivkeyHex";
290
+ privkeyHex: string;
291
+ };
292
+ feeSat?: number;
293
+ utxoPolicy?: "smallest_over" | "largest" | "newest";
294
+ broadcast?: boolean;
295
+ }) => ReturnType<typeof executeBondMachineSettlement>;
31
296
  loadBond: (input: {
32
297
  artifactPath: string;
33
298
  definitionPath?: string;
@@ -26,6 +26,26 @@ class SimplicityClient {
26
26
  this.bonds = {
27
27
  defineBond: async (input) => (0, bond_1.defineBond)(this, input),
28
28
  verifyBond: async (input) => (0, bond_1.verifyBond)(this, input),
29
+ redeemBond: async (input) => (0, bond_1.redeemBond)(this, input),
30
+ verifyBondTransition: async (input) => (0, bond_1.verifyBondTransition)(this, input),
31
+ buildBondRedemption: async (input) => (0, bond_1.buildBondRedemption)(this, input),
32
+ buildBondPayload: async (input) => (0, bond_1.buildBondPayload)(this, input),
33
+ buildBondTransitionPayload: async (input) => (0, bond_1.buildBondTransitionPayload)(this, input),
34
+ buildBondSettlementDescriptor: async (input) => (0, bond_1.buildBondSettlementDescriptor)(this, input),
35
+ verifyBondSettlementDescriptor: async (input) => (0, bond_1.verifyBondSettlementDescriptor)(this, input),
36
+ buildBondSettlementPayload: async (input) => (0, bond_1.buildBondSettlementPayload)(this, input),
37
+ buildBondRolloverPlan: async (input) => (0, bond_1.buildBondRolloverPlan)(this, input),
38
+ buildBondMachineRolloverPlan: async (input) => (0, bond_1.buildBondMachineRolloverPlan)(this, input),
39
+ buildBondMachineSettlementPlan: async (input) => (0, bond_1.buildBondMachineSettlementPlan)(this, input),
40
+ compileBondTransition: async (input) => (0, bond_1.compileBondTransition)(this, input),
41
+ compileBondRedemptionMachine: async (input) => (0, bond_1.compileBondRedemptionMachine)(this, input),
42
+ verifyBondRedemptionMachineArtifact: async (input) => (0, bond_1.verifyBondRedemptionMachineArtifact)(this, input),
43
+ inspectBondStateRollover: async (input) => (0, bond_1.inspectBondStateRollover)(this, input),
44
+ inspectBondMachineRollover: async (input) => (0, bond_1.inspectBondMachineRollover)(this, input),
45
+ inspectBondMachineSettlement: async (input) => (0, bond_1.inspectBondMachineSettlement)(this, input),
46
+ executeBondStateRollover: async (input) => (0, bond_1.executeBondStateRollover)(this, input),
47
+ executeBondMachineRollover: async (input) => (0, bond_1.executeBondMachineRollover)(this, input),
48
+ executeBondMachineSettlement: async (input) => (0, bond_1.executeBondMachineSettlement)(this, input),
29
49
  loadBond: async (input) => (0, bond_1.loadBond)(this, input),
30
50
  };
31
51
  }
@@ -153,6 +153,13 @@ export interface ArtifactStateMetadata {
153
153
  sourceVerified: boolean;
154
154
  };
155
155
  }
156
+ export type BondIssuanceStatus = "ISSUED" | "PARTIALLY_REDEEMED" | "REDEEMED";
157
+ export type BondTransitionType = "ISSUE" | "REDEEM";
158
+ export interface BondStateTransition {
159
+ type: BondTransitionType;
160
+ amount: number;
161
+ at: string;
162
+ }
156
163
  export interface DeploymentInfo {
157
164
  contractAddress: string;
158
165
  internalKey: string;
@@ -342,7 +349,33 @@ export interface BondIssuanceState {
342
349
  currencyAssetId: string;
343
350
  controllerXonly: string;
344
351
  issuedAt: string;
345
- status: "ISSUED" | "REDEEMED";
352
+ status: BondIssuanceStatus;
353
+ previousStateHash?: string | null;
354
+ lastTransition?: BondStateTransition;
355
+ }
356
+ export interface BondSettlementDescriptor {
357
+ settlementId: string;
358
+ bondId: string;
359
+ issuanceId: string;
360
+ definitionHash: string;
361
+ previousStateHash: string;
362
+ nextStateHash: string;
363
+ previousStatus: BondIssuanceStatus;
364
+ nextStatus: BondIssuanceStatus;
365
+ transitionKind: BondTransitionType;
366
+ redeemAmount: number;
367
+ transitionAt: string;
368
+ assetId: string;
369
+ nextContractAddress: string;
370
+ nextAmountSat: number;
371
+ maxFeeSat: number;
372
+ principal: {
373
+ issued: number;
374
+ previousOutstanding: number;
375
+ nextOutstanding: number;
376
+ previousRedeemed: number;
377
+ nextRedeemed: number;
378
+ };
346
379
  }
347
380
  export interface WaitForFundingInput {
348
381
  minAmountSat?: number;