Skip to content

Commit

Permalink
added missing schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinjangrzybowski committed Nov 5, 2024
1 parent 353d7ce commit a8ebfbd
Show file tree
Hide file tree
Showing 3 changed files with 337 additions and 24 deletions.
124 changes: 104 additions & 20 deletions pact-tests/pact-tests/ownera.repl
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
(expect "decode issue operation"
{"AHG": {
"amount": "1",
"assetId": "citi:102:d0c3eb56-0fff-4670-adfd-ad291a4314c3",
"assetType": "finp2p",
"dstAccount": "02fd7923740a775c95ce17e9bb7239ff9096689f70db9263a7efb9a9ad08e9fed7",
"dstAccountType": "finId",
"nonce": "16f56a399856b1a6243f5b9afb3e523ea73294be4c95ef0a0000000066d97261",
"operation": "issue"
},
"SHG": {
"amount": "10",
"assetId": "USD",
"assetType": "fiat",
"dstAccount": "03c48631f1d9ca0c89d8da8c7268e4d44f4223737829a9316d940352da3b25c40d",
"dstAccountType": "finId",
"srcAccount": "02fd7923740a775c95ce17e9bb7239ff9096689f70db9263a7efb9a9ad08e9fed7",
"srcAccountType": "finId"
}}
"x"

(ownera-decode-verified
{
Expand Down Expand Up @@ -110,5 +93,106 @@

}))


;; (ownera-decode-verified "primary-sale" {})
(expect "decode transfer operation"
"x"

(ownera-decode-verified
{
"signature": "b1444d7981bd543a24510a178a21a917ee261bcb531d4ef4dbee318e90a4992b30c995f232f87a3d993d8c7e4814cfe7552b6f9825de6dfe8b19b61ab7ffba0b",
"template": {
"hash": "5413f45cc5b03b0036f418813c96cbe469efe3f13395c19ff330955858636349",
"hashGroups": [
{
"fields": [
{
"name": "nonce",
"type": "bytes",
"value": "39fc89491a957fc72e12d7eb703c0bd23cd5c54ff612b97f0000000066d97bb6"
},
{
"name": "operation",
"type": "string",
"value": "transfer"
},
{
"name": "assetType",
"type": "string",
"value": "finp2p"
},
{
"name": "assetId",
"type": "string",
"value": "citi:102:d0c3eb56-0fff-4670-adfd-ad291a4314c3"
},
{
"name": "srcAccountType",
"type": "string",
"value": "finId"
},
{
"name": "srcAccount",
"type": "string",
"value": "02fd7923740a775c95ce17e9bb7239ff9096689f70db9263a7efb9a9ad08e9fed7"
},
{
"name": "dstAccountType",
"type": "string",
"value": "finId"
},
{
"name": "dstAccount",
"type": "string",
"value": "0354916de33408d1e30f638fc5920a57166867ded48c0f9098baf5f1a6c1c76676"
},
{
"name": "amount",
"type": "string",
"value": "1"
}
],
"hash": "1d36e25dcd84e29597d9e923446cb13930a8e59bf6cbbca02ee5909e290443a2"
},
{
"fields": [
{
"name": "assetType",
"type": "string",
"value": "fiat"
},
{
"name": "assetId",
"type": "string",
"value": "USD"
},
{
"name": "srcAccountType",
"type": "string",
"value": "finId"
},
{
"name": "srcAccount",
"type": "string",
"value": "0354916de33408d1e30f638fc5920a57166867ded48c0f9098baf5f1a6c1c76676"
},
{
"name": "dstAccountType",
"type": "string",
"value": "finId"
},
{
"name": "dstAccount",
"type": "string",
"value": "02fd7923740a775c95ce17e9bb7239ff9096689f70db9263a7efb9a9ad08e9fed7"
},
{
"name": "amount",
"type": "string",
"value": "1"
}
],
"hash": "e18bc18f23990e4a155bdce1afa9b15ef118624133b9af6401e84814a9d9bcf3"
}
],
"type": "hashList"
}
}))
2 changes: 1 addition & 1 deletion pact-tng.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ common pact-common
, trifecta
, hashable
-- hyperlane deps
, secp256k1-haskell >= 1.4.0
-- , secp256k1-haskell >= 1.4.0
, binary
, wide-word
, ethereum
Expand Down
235 changes: 232 additions & 3 deletions pact/Pact/Crypto/Ownera.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,53 @@ hashListSchema = HashListSchema . hls .



Loan -> undefined
Redeem -> undefined
Withdraw -> undefined
Loan ->
[("HG",["nonce"
,"operation"
,"pledgeAssetType"
,"pledgeAssetId"
,"pledgeBorrowerAccountType"
,"pledgeBorrowerAccountId"
,"pledgeLenderAccountType"
,"pledgeLenderAccountId"
,"pledgeAmount"
,"moneyAssetType"
,"moneyAssetId"
,"moneyLenderAccountType"
,"moneyLenderAccountId"
,"moneyBorrowerAccountType"
,"moneyBorrowerAccountId"
,"borrowedMoneyAmount"
,"returnedMoneyAmount"
,"openTime"
,"closeTime"])]
Redeem ->
[("AHG",["nonce"
,"operation"
,"assetType"
,"assetId"
,"srcAccountType"
,"srcAccount"
,"amount"])

,("SHG",["assetType"
,"assetId"
,"srcAccountType"
,"srcAccount"
,"dstAccountType"
,"dstAccount"
,"amount"])]

Withdraw ->
[("HG" , ["nonce"
,"operation"
,"assetType"
,"assetId"
,"srcAccountType"
,"srcAccount"
,"dstAccountType"
,"dstAccount"
,"amount"])]

where
hls :: [(Text , [Text])] -> [(Field , HashListGroupSchema)]
Expand Down Expand Up @@ -312,3 +356,188 @@ verifyOwneraSchemaStructure pkV = do
pure $ PObject $ fromList
[ ((Field "verified") , (PBool True))
, ((Field "data") , d) ]



-- verifyOwneraSchemaStructure :: OwneraSchemaId -> Map Field PactValue -> Either OwneraError ()
-- verifyOwneraSchemaStructure =
-- \case
-- Deposit ->
-- \om -> do
-- dhg <- grabHashGroup om (Field "DHG")
-- _ <- grabStrField dhg (Field "nonce")
-- _ <- grabStrField dhg (Field "operation")
-- _ <- grabStrField dhg (Field "assetType")
-- _ <- grabStrField dhg (Field "assetId")
-- _ <- grabStrField dhg (Field "dstAccountType")
-- _ <- grabStrField dhg (Field "dstAccount")
-- _ <- grabStrField dhg (Field "amount")
-- Right ()

-- -- Order Value Type Comment
-- -- 1 nonce string Explanation provided above.
-- -- 2 operation string "deposit"
-- -- 3 assetType string "fiat", "cryptocurrency", "finp2p", "custom"
-- -- 4 assetId string Unique identifier of the asset (blank for "custom")
-- -- 5 dstAccountType string "finId"
-- -- 6 dstAccount string Account to deposit the asset to
-- -- 7 amount string Amount to deposit


-- PrimarySale ->
-- \om -> do
-- ahg <- grabHashGroup om (Field "AHG")
-- _ <- grabStrField ahg (Field "nonce")
-- _ <- grabStrField ahg (Field "operation")
-- _ <- grabStrField ahg (Field "assetType")
-- _ <- grabStrField ahg (Field "assetId")
-- _ <- grabStrField ahg (Field "dstAccountType")
-- _ <- grabStrField ahg (Field "dstAccount")
-- _ <- grabStrField ahg (Field "amount")

-- shg <- grabHashGroup om (Field "SHG")
-- _ <- grabStrField shg (Field "assetType")
-- _ <- grabStrField shg (Field "assetId")
-- _ <- grabStrField shg (Field "srcAccountType")
-- _ <- grabStrField shg (Field "srcAccount")
-- _ <- grabStrField shg (Field "dstAccountType")
-- _ <- grabStrField shg (Field "dstAccount")
-- _ <- grabStrField shg (Field "amount")
-- Right ()
-- -- Order Value Type Comment
-- -- 1 nonce []byte Explanation provided above.
-- -- 2 operation string "issue"
-- -- 3 assetType string "finp2p"
-- -- 4 assetId string Unique identifier of the asset
-- -- 5 dstAccountType string "finId"
-- -- 6 dstAccount string Investor account finId address that will receive the tokens
-- -- 7 amount string Asset amount
-- -- Settlement Hash Group (SHG) Structure
-- -- Represents the payment/settlement instructions.

-- -- Order Value Type Comment
-- -- 1 assetType string "finp2p", "fiat", "cryptocurrency"
-- -- 2 assetId string Unique identifier of the asset
-- -- 3 srcAccountType string "finId"
-- -- 4 srcAccount string Investor account finId address for the payment asset
-- -- 5 dstAccountType string "finId"
-- -- 6 dstAccount string Issuer account finId address for the payment asset
-- -- 7 amount string Settlement amount


-- SecondarySale ->
-- \om -> do
-- ahg <- grabHashGroup om (Field "AHG")
-- _ <- grabStrField ahg (Field "nonce")
-- _ <- grabStrField ahg (Field "operation")
-- _ <- grabStrField ahg (Field "assetType")
-- _ <- grabStrField ahg (Field "assetId")
-- _ <- grabStrField ahg (Field "srcAccountType")
-- _ <- grabStrField ahg (Field "srcAccount")
-- _ <- grabStrField ahg (Field "dstAccountType")
-- _ <- grabStrField ahg (Field "dstAccount")
-- _ <- grabStrField ahg (Field "amount")

-- shg <- grabHashGroup om (Field "SHG")
-- _ <- grabStrField shg (Field "assetType")
-- _ <- grabStrField shg (Field "assetId")
-- _ <- grabStrField shg (Field "srcAccountType")
-- _ <- grabStrField shg (Field "srcAccount")
-- _ <- grabStrField shg (Field "dstAccountType")
-- _ <- grabStrField shg (Field "dstAccount")
-- _ <- grabStrField shg (Field "amount")

-- Right ()

-- -- Asset Hash Group (AHG) Structure
-- -- Represents the asset instructions.

-- -- Order Value Type Comment
-- -- 1 nonce []byte Explanation provided abo
-- -- 2 operation string "transfer"
-- -- 3 assetType string "finp2p"
-- -- 4 assetId string Unique identifier of the asset
-- -- 5 srcAccountType string "finId"
-- -- 6 srcAccount string Seller account finId address that will has the tokens
-- -- 7 dstAccountType string "finId"
-- -- 8 dstAccount string Buyer account finId address that will receive the tokens
-- -- 9 amount string Asset amount
-- -- Settlement Hash Group (SHG) Structure
-- -- Represents the payment/settlement instructions.

-- -- Order Value Type Comment
-- -- 1 assetType string "finp2p", "fiat", "cryptocurrency"
-- -- 2 assetId string Unique identifier of the asset
-- -- 3 srcAccountType string "finId"
-- -- 4 srcAccount string Buyer account findId address for the payment asset
-- -- 5 dstAccountType string "finId"
-- -- 6 dstAccount string Seller account findId address for the payment asset
-- -- 7 amount string Settlement amount

-- Loan ->
-- \om -> do
-- hg <- grabHashGroup om (Field "HG")
-- _ <- grabStrField hg (Field "nonce")
-- _ <- grabStrField hg (Field "operation")
-- _ <- grabStrField hg (Field "pledgeAssetType")
-- _ <- grabStrField hg (Field "pledgeAssetId")
-- _ <- grabStrField hg (Field "pledgeBorrowerAccountType")
-- _ <- grabStrField hg (Field "pledgeBorrowerAccountId")
-- _ <- grabStrField hg (Field "pledgeLenderAccountType")
-- _ <- grabStrField hg (Field "pledgeLenderAccountId")
-- _ <- grabStrField hg (Field "pledgeAmount")
-- _ <- grabStrField hg (Field "moneyAssetType")
-- _ <- grabStrField hg (Field "moneyAssetId")
-- _ <- grabStrField hg (Field "moneyLenderAccountType")
-- _ <- grabStrField hg (Field "moneyLenderAccountId")
-- _ <- grabStrField hg (Field "moneyBorrowerAccountType")
-- _ <- grabStrField hg (Field "moneyBorrowerAccountId")
-- _ <- grabStrField hg (Field "borrowedMoneyAmount")
-- _ <- grabStrField hg (Field "returnedMoneyAmount")
-- _ <- grabStrField hg (Field "openTime")
-- _ <- grabStrField hg (Field "closeTime")
-- Right ()

-- -- Order Value Type Comment
-- -- 1 nonce []byte Explanation provided above.
-- -- 2 operation string "loan"
-- -- 3 pledgeAssetType string "finp2p"
-- -- 4 pledgeAssetId string Unique identifier of the asset
-- -- 5 pledgeBorrowerAccountType string "finId"
-- -- 6 pledgeBorrowerAccountId string Borrower account
-- -- 7 pledgeLenderAccountType string "finId"
-- -- 8 pledgeLenderAccountId string Lender account
-- -- 9 pledgeAmount string Pledged asset amount
-- -- 10 moneyAssetType string "fiat"
-- -- 11 moneyAssetId string Unique identified of the asset
-- -- 12 moneyLenderAccountType string "finId"
-- -- 13 moneyLenderAccountId string Lender account
-- -- 14 moneyBorrowerAccountType string "finId"
-- -- 15 moneyBorrowerAccountId string Borrower account
-- -- 16 borrowedMoneyAmount string Lender settlement amount
-- -- 17 returnedMoneyAmount string Returned money at maturity, which includes applicable interest
-- -- 18 openTime string Settlement time for Loan, EPOCH in seconds
-- -- 19 closeTime string Maturity time for Loan, EPOCH in seconds

-- Redeem ->
-- \om -> do
-- ahg <- grabHashGroup om (Field "AHG")
-- _ <- grabStrField ahg (Field "nonce")
-- _ <- grabStrField ahg (Field "operation")
-- _ <- grabStrField ahg (Field "assetType")
-- _ <- grabStrField ahg (Field "assetId")
-- _ <- grabStrField ahg (Field "srcAccountType")
-- _ <- grabStrField ahg (Field "srcAccount")
-- _ <- grabStrField ahg (Field "amount")

-- shg <- grabHashGroup om (Field "SHG")
-- _ <- grabStrField shg (Field "assetType")
-- _ <- grabStrField shg (Field "assetId")
-- _ <- grabStrField shg (Field "srcAccountType")
-- _ <- grabStrField shg (Field "srcAccount")
-- _ <- grabStrField shg (Field "dstAccountType")
-- _ <- grabStrField shg (Field "dstAccount")
-- _ <- grabStrField shg (Field "amount")

-- Right ()

0 comments on commit a8ebfbd

Please sign in to comment.