Skip to content

Commit

Permalink
Add remark tags, and attestation signature type (#2565)
Browse files Browse the repository at this point in the history
* Fix reserve value in NAV management

* Fix remark attestation content

* Add signature type

* Remove console.log
  • Loading branch information
hieronx authored Dec 20, 2024
1 parent 6fb928f commit 164dc4f
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,23 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) {
},
}

let signature: { hash: string; publicKey: string } | null = null
let signature: { hash: string; publicKey: string; type: 'evm' | 'substrate' } | null = null
try {
const message = JSON.stringify(attestation.portfolio)
if (provider) {
const signer = await provider.getSigner()
const sig = await signer.signMessage(message)
const hash = keccak256(toUtf8Bytes(`\x19Ethereum Signed Message:\n${message.length}${message}`))
const recoveredPubKey = SigningKey.recoverPublicKey(hash, sig)
signature = { hash: sig, publicKey: recoveredPubKey }
signature = { hash: sig, publicKey: recoveredPubKey, type: 'evm' }
} else if (substrate.selectedAccount?.address && substrate?.selectedWallet?.signer?.signRaw) {
const { address } = substrate.selectedAccount
const { signature: sig } = await substrate.selectedWallet.signer.signRaw({
address: address,
data: stringToHex(message),
type: 'bytes',
})
signature = { hash: sig, publicKey: addressToHex(address) }
signature = { hash: sig, publicKey: addressToHex(address), type: 'substrate' }
}
} catch {}
if (!signature) return null
Expand Down Expand Up @@ -258,7 +258,10 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) {
return api.tx.oraclePriceFeed.feed(feed, CurrencyBalance.fromFloat(f.value, 18))
}),
api.tx.oraclePriceCollection.updateCollection(poolId),
api.tx.remarks.remark([{ Named: attestationHash }], api.tx.loans.updatePortfolioValuation(poolId)),
api.tx.remarks.remark(
[{ Named: `attestation:${poolId}:${attestationHash}` }],
api.tx.loans.updatePortfolioValuation(poolId)
),
api.tx.utility.batch(updateTokenPricesTxs),
]

Expand Down

0 comments on commit 164dc4f

Please # to comment.