Skip to content

Commit 4efbdd8

Browse files
committed
feat: copy event signature logic to error signatures
Signed-off-by: Simon Gellis <[email protected]>
1 parent 1f4d2f9 commit 4efbdd8

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

internal/blockchain/cardano/cardano.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,11 @@ func (c *Cardano) GenerateEventSignatureWithLocation(ctx context.Context, event
432432
}
433433

434434
func (c *Cardano) GenerateErrorSignature(ctx context.Context, event *fftypes.FFIErrorDefinition) string {
435-
// TODO: impl
436-
return ""
435+
params := []string{}
436+
for _, param := range event.Params {
437+
params = append(params, param.Schema.JSONObject().GetString("type"))
438+
}
439+
return fmt.Sprintf("%s(%s)", event.Name, strings.Join(params, ","))
437440
}
438441

439442
func (c *Cardano) GenerateFFI(ctx context.Context, generationRequest *fftypes.FFIGenerationRequest) (*fftypes.FFI, error) {

internal/blockchain/cardano/cardano_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,9 +1586,17 @@ func TestGenerateEventSignatureWithInvalidLocation(t *testing.T) {
15861586
func TestGenerateErrorSignature(t *testing.T) {
15871587
c, cancel := newTestCardano()
15881588
defer cancel()
1589-
1590-
signature := c.GenerateErrorSignature(context.Background(), nil)
1591-
assert.Equal(t, "", signature)
1589+
event := &fftypes.FFIErrorDefinition{
1590+
Name: "TransactionFailed",
1591+
Params: fftypes.FFIParams{
1592+
&fftypes.FFIParam{
1593+
Name: "transactionId",
1594+
Schema: fftypes.JSONAnyPtr(`{"type": "string"}`),
1595+
},
1596+
},
1597+
}
1598+
signature := c.GenerateErrorSignature(context.Background(), event)
1599+
assert.Equal(t, "TransactionFailed(string)", signature)
15921600
}
15931601

15941602
func TestCheckOverlappingLocationsEmpty(t *testing.T) {

0 commit comments

Comments
 (0)