Repository navigation
Protocol 30 (CAP-0084, CAP-0087, CAP-0088) #6015
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
Changes from 5 commits
2aa1702
50ebbb6
c754cbf
73e446d
25819d0
70bad4e
10bc40c
b9daf77
dde8ed4
174b61f
663a89a
eaed7ab
f981faf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ var ( | |
|
|
||
| someContract2 = strkey.MustEncode(strkey.VersionByteContract, someContractId2[:]) | ||
|
|
||
| someMuxedContract1 = strkey.MustEncode(strkey.VersionByteMuxedContract, append(someContractId1[:], 0, 0, 0, 0, 0, 0, 0, 7)) | ||
|
|
||
| processor = &EventsProcessor{ | ||
| networkPassphrase: someNetworkPassphrase, | ||
| } | ||
|
|
@@ -60,6 +62,17 @@ func createAddress(address string) xdr.ScVal { | |
| scAddress.Type = xdr.ScAddressTypeScAddressTypeAccount | ||
| scAddress.AccountId = xdr.MustAddressPtr(address) | ||
|
|
||
| case strkey.IsValidMuxedContractAddress(address) == true: | ||
| muxed, err := strkey.DecodeMuxedContract(address) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| scAddress.Type = xdr.ScAddressTypeScAddressTypeMuxedContract | ||
| scAddress.MuxedContract = &xdr.MuxedContract{ | ||
| Id: xdr.Uint64(muxed.ID()), | ||
| ContractId: muxed.Contract(), | ||
| } | ||
|
|
||
| default: | ||
| panic(fmt.Errorf("unsupported address: %s", address)) | ||
| } | ||
|
|
@@ -1211,6 +1224,24 @@ func TestValidSep41EventsWithExtraTopicsAndDataV4(t *testing.T) { | |
| assert.Equal(t, thousandStr, event.GetTransfer().Amount) | ||
| assert.Nil(t, event.Meta.GetToMuxedInfo()) | ||
| }, | ||
| }, { | ||
| name: "Transfer Event with muxed contract address in topics - Valid Sep-41 token", | ||
| setupEvent: func() xdr.ContractEvent { | ||
| topics := []xdr.ScVal{ | ||
| createSymbol(TransferEvent), | ||
| createAddress(randomAccount), // from | ||
| createAddress(someMuxedContract1), // to | ||
|
Comment on lines
+1231
to
+1233
|
||
| } | ||
| data := createInt128(thousand) | ||
|
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. https://github.com/stellar/stellar-protocol/blob/master/core/cap-0084.md#events to/from are not the W muxed contract address. It should just be the plain address
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. Ah actually this is valid for a non-sac transfer Maybe we should just add a test for sac transfer with muxed contract as linked in the cap above
Edit: nvm I don't think TTP should intentionally convert. We already accept M addresses the same way |
||
| return createContract(&someContractId1, topics, data) | ||
| }, | ||
| validateEvent: func(t *testing.T, event *TokenTransferEvent) { | ||
| assert.NotNil(t, event.GetTransfer()) | ||
| assert.Equal(t, randomAccount, event.GetTransfer().From) | ||
| assert.Equal(t, someMuxedContract1, event.GetTransfer().To) | ||
| assert.Equal(t, thousandStr, event.GetTransfer().Amount) | ||
| assert.Nil(t, event.Meta.GetToMuxedInfo()) | ||
| }, | ||
| }, | ||
|
|
||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
this tests one case but not the other.
This case has the
W....address in thetotopic and a barei128indata.Only a custom SEP-41 token emits that shape. The SAC never does.
Per CAP-0084 Events, a SAC transfer to a
W...address looks like this:The processor already handles it (same path as M destinations) but no test pins it.
Can we add this case, plus a a test for
mintas well?{ name: "SAC transfer to muxed contract: plain C in topic, to_muxed_id in data", setupEvent: func() xdr.ContractEvent { topics := []xdr.ScVal{ createSymbol(TransferEvent), createAddress(randomAccount), // from createAddress(someContract1), // to: plain C, not W createString(usdcAsset.StringCanonical()), // sep0011 asset } data := createScMap("amount", createInt128(thousand), "to_muxed_id", uint64(7)) return createContract(contractIdFromAsset(usdcAsset), topics, data) }, validateEvent: func(t *testing.T, event *TokenTransferEvent) { assert.Equal(t, someContract1, event.GetTransfer().To) assert.EqualValues(t, 7, event.Meta.GetToMuxedInfo().GetId()) assert.NotNil(t, event.GetTransfer().Asset) }, },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.
Added
TestSacEventsToMuxedContractV4in f981faf. It covers a SAC transfer and a SAC mint with the plainC...address in the topics and{amount, to_muxed_id: 7}as data, and checksTo,Amount, the asset andToMuxedInfo. The existing "V4 Transfer SAC Event - With Memo" case already had the transfer shape, but nothing tied it to CAP-0084, and mint was not covered.