-
Notifications
You must be signed in to change notification settings - Fork 6
feat: track witness set for transaction #1027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
eb6ab54
6d6530d
c3fa7a0
dab5d82
6f5b11b
04852d0
3260f67
ffb53dc
d351aa8
d8edaf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright 2025 Blink Labs Software | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package models | ||
|
|
||
| // RedeemerTag represents the tag for a redeemer (spend, mint, cert, reward, voting, proposing) | ||
| type RedeemerTag uint8 | ||
|
|
||
| const ( | ||
| RedeemerTagSpend RedeemerTag = 0 | ||
| RedeemerTagMint RedeemerTag = 1 | ||
| RedeemerTagCert RedeemerTag = 2 | ||
| RedeemerTagReward RedeemerTag = 3 | ||
| RedeemerTagVoting RedeemerTag = 4 | ||
| RedeemerTagProposing RedeemerTag = 5 | ||
| ) | ||
|
||
|
|
||
| // Redeemer represents a redeemer in the witness set | ||
| type Redeemer struct { | ||
| ID uint `gorm:"primaryKey"` | ||
| TransactionID uint `gorm:"index"` | ||
| Tag uint8 `gorm:"index"` // RedeemerTag | ||
| Index uint32 `gorm:"index"` | ||
| Data []byte `gorm:"type:bytea"` // Plutus data | ||
|
||
| ExUnitsMemory uint64 | ||
| ExUnitsCPU uint64 | ||
| Transaction *Transaction | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably don't want/need this reference back to |
||
| } | ||
|
|
||
| func (Redeemer) TableName() string { | ||
| return "redeemer" | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this file to |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright 2025 Blink Labs Software | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package models | ||
|
|
||
| // ScriptType represents the type of script | ||
| type ScriptType uint8 | ||
|
|
||
| const ( | ||
| ScriptTypeNative ScriptType = 0 | ||
| ScriptTypePlutusV1 ScriptType = 1 | ||
| ScriptTypePlutusV2 ScriptType = 2 | ||
| ScriptTypePlutusV3 ScriptType = 3 | ||
| ) | ||
jkawan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Script represents a script entry in the witness set | ||
| type Script struct { | ||
|
||
| ID uint `gorm:"primaryKey"` | ||
| TransactionID uint `gorm:"index"` | ||
| Type uint8 `gorm:"index"` // ScriptType (0=Native, 1=PlutusV1, 2=PlutusV2, 3=PlutusV3) | ||
| ScriptData []byte `gorm:"type:bytea"` | ||
|
||
| Transaction *Transaction | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably don't want/need this reference back to |
||
| } | ||
agaffney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| func (Script) TableName() string { | ||
| return "script" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,14 +16,18 @@ package models | |
|
|
||
| // Transaction represents a transaction record | ||
| type Transaction struct { | ||
| Hash []byte `gorm:"uniqueIndex"` | ||
| BlockHash []byte `gorm:"index"` | ||
| Inputs []Utxo `gorm:"foreignKey:SpentAtTxId;references:Hash"` | ||
| Outputs []Utxo `gorm:"foreignKey:TransactionID;references:ID"` | ||
| ReferenceInputs []Utxo `gorm:"foreignKey:ReferencedByTxId;references:Hash"` | ||
| Collateral []Utxo `gorm:"foreignKey:CollateralByTxId;references:Hash"` | ||
| CollateralReturn *Utxo `gorm:"foreignKey:TransactionID;references:ID"` | ||
| ID uint `gorm:"primaryKey"` | ||
| Hash []byte `gorm:"uniqueIndex"` | ||
| BlockHash []byte `gorm:"index"` | ||
| Inputs []Utxo `gorm:"foreignKey:SpentAtTxId;references:Hash"` | ||
| Outputs []Utxo `gorm:"foreignKey:TransactionID;references:ID"` | ||
| ReferenceInputs []Utxo `gorm:"foreignKey:ReferencedByTxId;references:Hash"` | ||
| Collateral []Utxo `gorm:"foreignKey:CollateralByTxId;references:Hash"` | ||
| CollateralReturn *Utxo `gorm:"foreignKey:TransactionID;references:ID"` | ||
| Witnesses []Witness `gorm:"foreignKey:TransactionID;references:ID"` | ||
jkawan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Scripts []Script `gorm:"foreignKey:TransactionID;references:ID"` | ||
|
||
| Redeemers []Redeemer `gorm:"foreignKey:TransactionID;references:ID"` | ||
| PlutusDataList []PlutusData `gorm:"foreignKey:TransactionID;references:ID"` | ||
jkawan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ID uint `gorm:"primaryKey"` | ||
| Type int | ||
| BlockIndex uint32 | ||
| Metadata []byte | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright 2025 Blink Labs Software | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package models | ||
|
|
||
| // WitnessType represents the type of witness | ||
| type WitnessType uint8 | ||
|
|
||
| const ( | ||
| WitnessTypeVkey WitnessType = 0 | ||
| WitnessTypeBootstrap WitnessType = 1 | ||
| ) | ||
|
|
||
| // Witness represents a witness entry (Vkey or Bootstrap) | ||
| type Witness struct { | ||
jkawan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ID uint `gorm:"primaryKey"` | ||
| TransactionID uint `gorm:"index"` | ||
| Type uint8 `gorm:"index"` // WitnessType (0=Vkey, 1=Bootstrap) | ||
| Vkey []byte `gorm:"type:bytea"` | ||
| Signature []byte `gorm:"type:bytea"` | ||
| PublicKey []byte `gorm:"type:bytea"` // For Bootstrap | ||
| ChainCode []byte `gorm:"type:bytea"` // For Bootstrap | ||
| Attributes []byte `gorm:"type:bytea"` // For Bootstrap | ||
| Transaction *Transaction | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably don't want/need this reference back to |
||
| } | ||
|
|
||
| func (Witness) TableName() string { | ||
| return "witness" | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the GORM field type override. This is a Postgres column type that won't work in SQLite