Skip to content

vela-ventures/permaswap-token-patch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Patch for new tokens listed on Permaswap

Define globally:

-- Tags to preserve case
local preservedCaseTags = {
    ["X-Ffp-For"] = "X-FFP-For",
    ["X-Ffp-Settleid"] = "X-FFP-SettleID",
    ["X-Ffp-Refundtosettler"] = "X-FFP-RefundToSettler",
    ["X-Ffp-Noteid"] = "X-FFP-NoteID",
    ["X-Ffp-Noteids"] = "X-FFP-NoteIDs",
    ["X-Ffp-Error"] = "X-FFP-Error",
    ["X-Ffp-Txin"] = "X-FFP-TxIn",
    ["X-Ffp-Settleddate"] = "X-FFP-SettledDate",
    ["X-Ffp-Failedtostartsettle"] = "X-FFP-FailedToStartSettle",
    ["X-Ffp-Reason"] = "X-FFP-Reason"
}

Inside the tokens Transfer handler:

-- Add forwarded tags to the credit and debit notice messages
for tagName, tagValue in pairs(msg) do
    -- Tags beginning with "X-" are forwarded
    if string.sub(tagName, 1, 2) == "X-" then
        debitNotice[tagName] = tagValue
        creditNotice[tagName] = tagValue
    end


    -- CHANGE START --

    -- Additionally forward Permaswap tags with their original case
    if preservedCaseTags[tagName] then
        debitNotice[preservedCaseTags[tagName]] = tagValue
        creditNotice[preservedCaseTags[tagName]] = tagValue
    end

    -- CHANGE END --
end

The expected behaviour is to forward tags as per usual, but Permaswap specific tags will be forwarded in their original case and camel case

About

Backwards compatibility for new tokens on Permaswap

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published