Skip to content
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

Add remark tags, and attestation signature type #2565

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading