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

Update B512Type.ts #3287

Closed
wants to merge 1 commit into from
Closed
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
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.