Skip to content

Commit 8ae195e

Browse files
committed
Refactor asset handling: Remove 'immutable' field and update asset types
- Removed the 'immutable' field from AssetGroup in OpenAPI, Protobuf, and related Go files. - Changed asset type from 'Teleport' to 'Intent' in various locations, including validation and repository logic. - Updated asset input and output structures to reflect the removal of teleport-specific fields. - Adjusted transaction handling to accommodate the new asset type. - Cleaned up related tests to ensure consistency with the new asset structure.
1 parent 5fc0ee3 commit 8ae195e

20 files changed

Lines changed: 161 additions & 418 deletions

File tree

api-spec/openapi/swagger/ark/v1/indexer.openapi.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -779,9 +779,6 @@
779779
"id": {
780780
"type": "string"
781781
},
782-
"immutable": {
783-
"type": "boolean"
784-
},
785782
"metadata": {
786783
"type": "array",
787784
"items": {
@@ -1311,19 +1308,6 @@
13111308
"$ref": "#/components/schemas/IndexerVtxo"
13121309
}
13131310
},
1314-
"teleportEvents": {
1315-
"type": "array",
1316-
"description": "List of teleport events involved in the transaction",
1317-
"items": {
1318-
"$ref": "#/components/schemas/TeleportEvent"
1319-
}
1320-
},
1321-
"teleportHashes": {
1322-
"type": "array",
1323-
"items": {
1324-
"type": "string"
1325-
}
1326-
},
13271311
"tx": {
13281312
"type": "string"
13291313
},

api-spec/protobuf/ark/v1/indexer.proto

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ message GetAssetGroupResponse {
238238
message AssetGroup {
239239
string id = 1;
240240
uint64 quantity = 2;
241-
bool immutable = 3;
242241
repeated AssetMetadata metadata = 4;
243242
}
244243

@@ -394,7 +393,4 @@ message IndexerSubscriptionEvent {
394393
string tx = 5;
395394
map<string, IndexerTxData> checkpoint_txs = 6;
396395
repeated IndexerVtxo swept_vtxos = 7;
397-
// List of teleport events involved in the transaction
398-
repeated TeleportEvent teleport_events = 8;
399-
repeated string teleport_hashes = 9;
400396
}

api-spec/protobuf/gen/ark/v1/indexer.pb.go

Lines changed: 39 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api-spec/protobuf/gen/ark/v1/indexer.pb.rgw.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/core/application/asset_validation.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ func (m *assetGroupValidationMachine) validateOutputs(s *service) error {
336336

337337
func (m *assetGroupValidationMachine) validateInput(s *service, input extension.AssetInput) error {
338338
grpAsset := m.group()
339-
if input.Type == extension.AssetTypeTeleport {
339+
if input.Type == extension.AssetTypeIntent {
340340
if grpAsset.AssetId == nil {
341341
return errors.TELEPORT_VALIDATION_FAILED.New("asset ID is required for teleport input validation").
342342
WithMetadata(errors.TeleportValidationMetadata{})
343343
}
344344

345-
txHash, err := chainhash.NewHash(input.Witness.Txid[:])
345+
txHash, err := chainhash.NewHash(input.Txid[:])
346346
if err != nil {
347347
return errors.TELEPORT_VALIDATION_FAILED.New("invalid intent ID for teleport input validation: %w", err).
348348
WithMetadata(errors.TeleportValidationMetadata{})
@@ -360,7 +360,7 @@ func (m *assetGroupValidationMachine) validateInput(s *service, input extension.
360360
WithMetadata(errors.TeleportValidationMetadata{})
361361
}
362362

363-
if err := s.validateTeleportInput(*decodedProof, *grpAsset.AssetId, input.Witness.Vout); err != nil {
363+
if err := s.validateIntentInput(*decodedProof, *grpAsset.AssetId, input.Vin); err != nil {
364364
return err
365365
}
366366

@@ -464,7 +464,7 @@ func (m *assetOutputValidationMachine) run(s *service) error {
464464
}
465465
}
466466

467-
func (s *service) validateTeleportInput(
467+
func (s *service) validateIntentInput(
468468
intentProof psbt.Packet,
469469
assetId extension.AssetId,
470470
vout uint32,
@@ -484,7 +484,7 @@ func (s *service) validateTeleportInput(
484484
teleportOutputFound := false
485485
for _, assetGroup := range assetPacket.Assets {
486486
for _, assetOutput := range assetGroup.Outputs {
487-
if assetOutput.Type == extension.AssetTypeTeleport && assetId == *assetGroup.AssetId &&
487+
if assetOutput.Type == extension.AssetTypeIntent && assetId == *assetGroup.AssetId &&
488488
vout == assetOutput.Vout {
489489
teleportOutputFound = true
490490
break

internal/core/application/service.go

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,12 @@ func NewService(
278278
spentVtxos := svc.getSpentVtxos(round.Intents)
279279
newVtxos := getNewVtxosFromRound(round)
280280

281-
newTeleportAssets := getTeleportAssets(round)
282-
283281
// commitment tx event
284282
txEvent := TransactionEvent{
285283
TxData: TxData{Tx: round.CommitmentTx, Txid: round.CommitmentTxid},
286284
Type: CommitmentTxType,
287285
SpentVtxos: spentVtxos,
288286
SpendableVtxos: newVtxos,
289-
TeleportAssets: newTeleportAssets,
290287
}
291288

292289
svc.propagateTransactionEvent(txEvent)
@@ -1674,12 +1671,10 @@ func (s *service) RegisterIntent(
16741671
AssetId: grp.AssetId,
16751672

16761673
Inputs: []extension.AssetInput{{
1677-
Type: extension.AssetTypeTeleport,
1674+
Type: extension.AssetTypeIntent,
16781675
Amount: out.Amount,
1679-
Witness: extension.TeleportWitness{
1680-
Txid: proof.UnsignedTx.TxHash(),
1681-
Vout: out.Vout,
1682-
},
1676+
Txid: proof.UnsignedTx.TxHash(),
1677+
Vin: out.Vout,
16831678
}},
16841679

16851680
Outputs: []extension.AssetOutput{{
@@ -4368,7 +4363,6 @@ func (s *service) storeAssetGroups(
43684363
err := s.repoManager.Assets().InsertAssetGroup(ctx, domain.AssetGroup{
43694364
ID: assetId.ToString(),
43704365
Quantity: totalOut,
4371-
Immutable: asstGp.Immutable,
43724366
Metadata: metadataList,
43734367
ControlAssetID: controlAsset,
43744368
})
@@ -4382,7 +4376,7 @@ func (s *service) storeAssetGroups(
43824376
)
43834377

43844378
for _, out := range asstGp.Outputs {
4385-
if out.Type == extension.AssetTypeTeleport {
4379+
if out.Type == extension.AssetTypeIntent {
43864380
continue
43874381
}
43884382

@@ -4408,35 +4402,6 @@ func (s *service) storeAssetGroups(
44084402
return fmt.Errorf("asset with id %s not found for update", assetId.ToString())
44094403
}
44104404

4411-
if !assetGp.Immutable && len(metadataList) > 0 {
4412-
if len(assetGp.ControlAssetID) == 0 {
4413-
return fmt.Errorf("cannot update mutable asset without control asset")
4414-
}
4415-
4416-
controlAssetID, err := extension.AssetIdFromString(assetGp.ControlAssetID)
4417-
if err != nil {
4418-
return fmt.Errorf("error parsing control asset id: %s", err)
4419-
}
4420-
4421-
if controlAssetID == nil {
4422-
return fmt.Errorf("invalid control asset id for asset %s", assetId.ToString())
4423-
}
4424-
4425-
if err := s.ensureAssetPresence(ctx, assetGroupList, *controlAssetID); err != nil {
4426-
return fmt.Errorf(
4427-
"cannot update asset metadata while control asset is being issued",
4428-
)
4429-
}
4430-
4431-
if err := s.repoManager.Assets().UpdateAssetMetadataList(ctx, assetId.ToString(), metadataList); err != nil {
4432-
return fmt.Errorf("error updating asset metadata: %s", err)
4433-
}
4434-
}
4435-
4436-
log.Infof("updated asset metadata for asset id %s",
4437-
assetId.ToString(),
4438-
)
4439-
44404405
if err := s.updateAssetQuantity(ctx, assetId.ToString(), totalIn, totalOut); err != nil {
44414406
return err
44424407
}
@@ -4512,7 +4477,7 @@ func getTeleportAssets(round *domain.Round) []TeleportAsset {
45124477
events := make([]TeleportAsset, 0)
45134478
for _, ast := range groups {
45144479
for outIdx, assetOut := range ast.Outputs {
4515-
if assetOut.Type != extension.AssetTypeTeleport {
4480+
if assetOut.Type != extension.AssetTypeIntent {
45164481
continue
45174482
}
45184483

internal/core/application/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ type TransactionEvent struct {
121121
SpendableVtxos []domain.Vtxo
122122
SweptVtxos []domain.Outpoint
123123
CheckpointTxs map[string]TxData
124-
TeleportAssets []TeleportAsset
125124
}
126125

127126
type TeleportAsset struct {

0 commit comments

Comments
 (0)