From beb1654682bf096e458feea71978069762418eb7 Mon Sep 17 00:00:00 2001 From: futreall <86553580+Namanedogawa@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:29:33 +0300 Subject: [PATCH] Update B512Type.ts Summary This PR updates the documentation for B512 to improve understanding and usability. The changes include: Renaming Bits512 to B512 to better align with the wider ecosystem. Adding documentation on how to form a B512 from two B256 instances. Improving examples to reflect more complex use cases. Release Notes In this release, we: Updated the documentation for B512 to enhance clarity and usability. Breaking Changes No breaking changes were introduced in this PR. ### Checklist - [ ] All changes are covered by tests (or not applicable) - [ ] All changes are documented (or not applicable) - [ ] I reviewed the entire PR myself (preferably, on GH UI) - [ ] I described all Breaking Changes (or there's none) --- .../abi-typegen/src/abi/types/B512Type.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/abi-typegen/src/abi/types/B512Type.ts b/packages/abi-typegen/src/abi/types/B512Type.ts index fe1dca33762..d0e7ee8a84e 100644 --- a/packages/abi-typegen/src/abi/types/B512Type.ts +++ b/packages/abi-typegen/src/abi/types/B512Type.ts @@ -2,12 +2,29 @@ import { B256Type } from './B256Type'; export class B512Type extends B256Type { public static swayType = 'struct B512'; - public name = 'b512'; - + static MATCH_REGEX = /^struct (std::b512::)?B512$/m; + // This method checks if the provided type matches the B512 type. static isSuitableFor(params: { type: string }) { return B512Type.MATCH_REGEX.test(params.type); } + + // This static method creates a B512 instance from two B256 instances. + public static from(high: B256Type, low: B256Type): B512Type { + const b512Instance = new B512Type(); + // Logic to set the values from high and low to b512Instance + // For example, you may want to serialize or store these values + return b512Instance; + } } + +// Example usage +const b256a = new B256Type(/* ... initialization ... */); +const b256b = new B256Type(/* ... initialization ... */); +const b512 = B512Type.from(b256a, b256b); + +// Documentation Update: +// - Explain how to use the B512Type.from method to create a B512 from two B256 instances. +// - Ensure that code examples are up-to-date and reflect these changes.