feat(system-program): add createAccountWithSeed

This commit is contained in:
Rob Walker
2019-12-09 19:50:01 -08:00
committed by Michael Vines
parent cc550dfb08
commit 0760853871
4 changed files with 120 additions and 2 deletions

View File

@ -43,5 +43,25 @@ export const rustString = (property: string = 'string') => {
return _encode(data, buffer, offset);
};
rsl.alloc = str => {
return (
BufferLayout.u32().span +
BufferLayout.u32().span +
Buffer.from(str, 'utf8').length
);
};
return rsl;
};
export function getAlloc(type: Object, fields: Object): number {
let alloc = 0;
type.layout.fields.forEach(item => {
if (item.span >= 0) {
alloc += item.span;
} else if (typeof item.alloc === 'function') {
alloc += item.alloc(fields[item.property]);
}
});
return alloc;
}