Skip to content

Commit

Permalink
Update B512Type.ts
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
futreall authored Oct 9, 2024
1 parent 04578ed commit beb1654
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/abi-typegen/src/abi/types/B512Type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit beb1654

Please sign in to comment.