Skip to content

Commit

Permalink
feat: create spec by hand
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Aug 7, 2023
1 parent 9d71d68 commit 5fee3cf
Show file tree
Hide file tree
Showing 4 changed files with 1,872 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"eventsource": "^2.0.2",
"lodash": "^4.17.21",
"randombytes": "^2.1.0",
"stellar-base": "git+https://github.com/stellar/js-stellar-base.git#xdr-bump",
"stellar-base": "10.0.0-soroban.5",
"toml": "^3.0.0",
"urijs": "^1.19.1"
}
Expand Down
29 changes: 28 additions & 1 deletion src/contract_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ export class ContractSpec {
}

findEntry(name: string): xdr.ScSpecEntry {
console.log(name, JSON.stringify(this.entries, null, 2));
let entry = this.entries.find(
(entry) => entry.value().name.toString() === name
(entry) => entry.value().name().toString() === name
);
if (!entry) {
throw new Error(`no such entry: ${name}`);
Expand Down Expand Up @@ -614,3 +615,29 @@ function stringToScVal(
function isNumeric(field: xdr.ScSpecUdtStructFieldV0) {
return /^\d+$/.test(field.name() as string);
}

export const STRUCT = xdr.ScSpecEntry.scSpecEntryUdtStructV0(new xdr.ScSpecUdtStructV0(
{
doc: "This is from the rust doc above the struct Test",
lib: "",
name: "Test",
fields:
[
// new xdr.ScSpecUdtStructFieldV0({
// doc: "",
// name: "a",
// type: xdr.ScSpecTypeDef.scSpecTypeU32(),
// }),
new xdr.ScSpecUdtStructFieldV0 ({
doc: "",
name: "b",
type: xdr.ScSpecTypeDef.scSpecTypeBool(),
}),
// new xdr.ScSpecUdtStructFieldV0 ({
// doc: "",
// name: "c",
// type: xdr.ScSpecTypeDef.scSpecTypeSymbol(),
// }),
],

}));
Loading

0 comments on commit 5fee3cf

Please sign in to comment.