Skip to content

Commit 4dd685d

Browse files
committed
feat: replace standalone with local
1 parent 14bebd1 commit 4dd685d

4 files changed

Lines changed: 201 additions & 171 deletions

File tree

cmd/crates/soroban-spec-typescript/src/boilerplate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static PROJECT_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/src/project_temp
1414

1515
const NETWORK_PASSPHRASE_TESTNET: &str = "Test SDF Network ; September 2015";
1616
const NETWORK_PASSPHRASE_FUTURENET: &str = "Test SDF Future Network ; October 2022";
17-
const NETWORK_PASSPHRASE_STANDALONE: &str = "Standalone Network ; February 2017";
17+
const NETWORK_PASSPHRASE_LOCAL: &str = "Standalone Network ; February 2017";
1818

1919
pub struct Project(PathBuf);
2020

@@ -125,7 +125,7 @@ impl Project {
125125
let network = match network_passphrase {
126126
NETWORK_PASSPHRASE_TESTNET => "testnet",
127127
NETWORK_PASSPHRASE_FUTURENET => "futurenet",
128-
NETWORK_PASSPHRASE_STANDALONE => "standalone",
128+
NETWORK_PASSPHRASE_LOCAL => "local",
129129
_ => "unknown",
130130
};
131131
format!(
Lines changed: 184 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,193 +1,223 @@
1-
import test from 'ava'
2-
import { root, rpcUrl, signer } from './util.js'
3-
import { Client, networks, contract as ContractClient } from 'test-custom-types'
1+
import test from "ava";
2+
import { root, rpcUrl, signer } from "./util.js";
3+
import {
4+
Client,
5+
networks,
6+
contract as ContractClient,
7+
} from "test-custom-types";
48

59
const publicKey = root.keypair.publicKey();
610

711
const contract = new Client({
8-
...networks.standalone,
12+
...networks.local,
913
rpcUrl,
1014
allowHttp: true,
1115
publicKey: root.keypair.publicKey(),
1216
...signer,
1317
});
1418

15-
test('hello', async t => {
16-
const { result } = await contract.hello({ hello: 'tests' })
17-
t.is(result, 'tests')
18-
})
19+
test("hello", async (t) => {
20+
const { result } = await contract.hello({ hello: "tests" });
21+
t.is(result, "tests");
22+
});
1923

20-
test('woid', async t => {
21-
t.is((await contract.woid()).result, null)
22-
})
24+
test("woid", async (t) => {
25+
t.is((await contract.woid()).result, null);
26+
});
2327

24-
test('u32_fail_on_even', async t => {
28+
test("u32_fail_on_even", async (t) => {
2529
t.deepEqual(
2630
(await contract.u32_fail_on_even({ u32_: 1 })).result,
27-
new ContractClient.Ok(1)
28-
)
31+
new ContractClient.Ok(1),
32+
);
2933
t.deepEqual(
3034
(await contract.u32_fail_on_even({ u32_: 0 })).result,
31-
new ContractClient.Err({ message: "Please provide an odd number" })
32-
)
33-
})
35+
new ContractClient.Err({ message: "Please provide an odd number" }),
36+
);
37+
});
3438

35-
test('u32_', async t => {
36-
t.is((await contract.u32_({ u32_: 1 })).result, 1)
37-
})
39+
test("u32_", async (t) => {
40+
t.is((await contract.u32_({ u32_: 1 })).result, 1);
41+
});
3842

39-
test('i32_', async t => {
40-
t.is((await contract.i32_({ i32_: 1 })).result, 1)
41-
})
43+
test("i32_", async (t) => {
44+
t.is((await contract.i32_({ i32_: 1 })).result, 1);
45+
});
4246

43-
test('i64_', async t => {
44-
t.is((await contract.i64_({ i64_: 1n })).result, 1n)
45-
})
47+
test("i64_", async (t) => {
48+
t.is((await contract.i64_({ i64_: 1n })).result, 1n);
49+
});
4650

4751
test("strukt_hel", async (t) => {
48-
const test = { a: 0, b: true, c: "world" }
49-
t.deepEqual((await contract.strukt_hel({ strukt: test })).result, ["Hello", "world"])
50-
})
52+
const test = { a: 0, b: true, c: "world" };
53+
t.deepEqual((await contract.strukt_hel({ strukt: test })).result, [
54+
"Hello",
55+
"world",
56+
]);
57+
});
5158

5259
test("strukt", async (t) => {
53-
const test = { a: 0, b: true, c: "hello" }
54-
t.deepEqual((await contract.strukt({ strukt: test })).result, test)
55-
})
56-
57-
test('simple first', async t => {
58-
const arg = { tag: 'First', values: undefined } as const
59-
const ret = { tag: 'First' }
60-
t.deepEqual((await contract.simple({ simple: arg })).result, ret)
61-
})
62-
63-
test('simple second', async t => {
64-
const arg = { tag: 'Second', values: undefined } as const
65-
const ret = { tag: 'Second' }
66-
t.deepEqual((await contract.simple({ simple: arg })).result, ret)
67-
})
68-
69-
test('simple third', async t => {
70-
const arg = { tag: 'Third', values: undefined } as const
71-
const ret = { tag: 'Third' }
72-
t.deepEqual((await contract.simple({ simple: arg })).result, ret)
73-
})
74-
75-
test('complex with struct', async t => {
76-
const arg = { tag: 'Struct', values: [{ a: 0, b: true, c: 'hello' }] } as const
77-
const ret = { tag: 'Struct', values: [{ a: 0, b: true, c: 'hello' }] }
78-
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
79-
})
80-
81-
test('complex with tuple', async t => {
82-
const arg = { tag: 'Tuple', values: [[{ a: 0, b: true, c: 'hello' }, { tag: 'First', values: undefined }]] } as const
83-
const ret = { tag: 'Tuple', values: [[{ a: 0, b: true, c: 'hello' }, { tag: 'First' }]] }
84-
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
85-
})
86-
87-
test('complex with enum', async t => {
88-
const arg = { tag: 'Enum', values: [{ tag: 'First', values: undefined }] } as const
89-
const ret = { tag: 'Enum', values: [{ tag: 'First' }] }
90-
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
91-
})
92-
93-
test('complex with asset', async t => {
94-
const arg = { tag: 'Asset', values: [publicKey, 1n] } as const
95-
const ret = { tag: 'Asset', values: [publicKey, 1n] }
96-
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
97-
})
98-
99-
test('complex with void', async t => {
100-
const arg = { tag: 'Void', values: undefined } as const
101-
const ret = { tag: 'Void' }
102-
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
103-
})
104-
105-
test('addresse', async t => {
106-
t.deepEqual((await contract.addresse({ addresse: publicKey })).result, publicKey)
107-
})
108-
109-
test('bytes', async t => {
110-
const bytes = Buffer.from('hello')
111-
t.deepEqual((await contract.bytes({ bytes })).result, bytes)
112-
})
113-
114-
test('bytes_n', async t => {
115-
const bytes_n = Buffer.from('123456789') // what's the correct way to construct bytes_n?
116-
t.deepEqual((await contract.bytes_n({ bytes_n })).result, bytes_n)
117-
})
118-
119-
test('card', async t => {
120-
const card = 11
121-
t.is((await contract.card({ card })).result, card)
122-
})
123-
124-
test('boolean', async t => {
125-
t.is((await contract.boolean({ boolean: true })).result, true)
126-
})
127-
128-
test('not', async t => {
129-
t.is((await contract.not({ boolean: true })).result, false)
130-
})
131-
132-
test('i128', async t => {
133-
t.is((await contract.i128({ i128: -1n })).result, -1n)
134-
})
135-
136-
test('u128', async t => {
137-
t.is((await contract.u128({ u128: 1n })).result, 1n)
138-
})
139-
140-
test('multi_args', async t => {
141-
t.is((await contract.multi_args({ a: 1, b: true })).result, 1)
142-
t.is((await contract.multi_args({ a: 1, b: false })).result, 0)
143-
})
144-
145-
test('map', async t => {
146-
const map = new Map()
147-
map.set(1, true)
148-
map.set(2, false)
60+
const test = { a: 0, b: true, c: "hello" };
61+
t.deepEqual((await contract.strukt({ strukt: test })).result, test);
62+
});
63+
64+
test("simple first", async (t) => {
65+
const arg = { tag: "First", values: undefined } as const;
66+
const ret = { tag: "First" };
67+
t.deepEqual((await contract.simple({ simple: arg })).result, ret);
68+
});
69+
70+
test("simple second", async (t) => {
71+
const arg = { tag: "Second", values: undefined } as const;
72+
const ret = { tag: "Second" };
73+
t.deepEqual((await contract.simple({ simple: arg })).result, ret);
74+
});
75+
76+
test("simple third", async (t) => {
77+
const arg = { tag: "Third", values: undefined } as const;
78+
const ret = { tag: "Third" };
79+
t.deepEqual((await contract.simple({ simple: arg })).result, ret);
80+
});
81+
82+
test("complex with struct", async (t) => {
83+
const arg = {
84+
tag: "Struct",
85+
values: [{ a: 0, b: true, c: "hello" }],
86+
} as const;
87+
const ret = { tag: "Struct", values: [{ a: 0, b: true, c: "hello" }] };
88+
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
89+
});
90+
91+
test("complex with tuple", async (t) => {
92+
const arg = {
93+
tag: "Tuple",
94+
values: [
95+
[
96+
{ a: 0, b: true, c: "hello" },
97+
{ tag: "First", values: undefined },
98+
],
99+
],
100+
} as const;
101+
const ret = {
102+
tag: "Tuple",
103+
values: [[{ a: 0, b: true, c: "hello" }, { tag: "First" }]],
104+
};
105+
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
106+
});
107+
108+
test("complex with enum", async (t) => {
109+
const arg = {
110+
tag: "Enum",
111+
values: [{ tag: "First", values: undefined }],
112+
} as const;
113+
const ret = { tag: "Enum", values: [{ tag: "First" }] };
114+
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
115+
});
116+
117+
test("complex with asset", async (t) => {
118+
const arg = { tag: "Asset", values: [publicKey, 1n] } as const;
119+
const ret = { tag: "Asset", values: [publicKey, 1n] };
120+
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
121+
});
122+
123+
test("complex with void", async (t) => {
124+
const arg = { tag: "Void", values: undefined } as const;
125+
const ret = { tag: "Void" };
126+
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
127+
});
128+
129+
test("addresse", async (t) => {
130+
t.deepEqual(
131+
(await contract.addresse({ addresse: publicKey })).result,
132+
publicKey,
133+
);
134+
});
135+
136+
test("bytes", async (t) => {
137+
const bytes = Buffer.from("hello");
138+
t.deepEqual((await contract.bytes({ bytes })).result, bytes);
139+
});
140+
141+
test("bytes_n", async (t) => {
142+
const bytes_n = Buffer.from("123456789"); // what's the correct way to construct bytes_n?
143+
t.deepEqual((await contract.bytes_n({ bytes_n })).result, bytes_n);
144+
});
145+
146+
test("card", async (t) => {
147+
const card = 11;
148+
t.is((await contract.card({ card })).result, card);
149+
});
150+
151+
test("boolean", async (t) => {
152+
t.is((await contract.boolean({ boolean: true })).result, true);
153+
});
154+
155+
test("not", async (t) => {
156+
t.is((await contract.not({ boolean: true })).result, false);
157+
});
158+
159+
test("i128", async (t) => {
160+
t.is((await contract.i128({ i128: -1n })).result, -1n);
161+
});
162+
163+
test("u128", async (t) => {
164+
t.is((await contract.u128({ u128: 1n })).result, 1n);
165+
});
166+
167+
test("multi_args", async (t) => {
168+
t.is((await contract.multi_args({ a: 1, b: true })).result, 1);
169+
t.is((await contract.multi_args({ a: 1, b: false })).result, 0);
170+
});
171+
172+
test("map", async (t) => {
173+
const map = new Map();
174+
map.set(1, true);
175+
map.set(2, false);
149176
// map.set(3, 'hahaha') // should throw an error
150-
const ret = Array.from(map.entries())
151-
t.deepEqual((await contract.map({ map })).result, ret)
152-
})
177+
const ret = Array.from(map.entries());
178+
t.deepEqual((await contract.map({ map })).result, ret);
179+
});
153180

154-
test('vec', async t => {
155-
const vec = [1, 2, 3]
156-
t.deepEqual((await contract.vec({ vec })).result, vec)
157-
})
181+
test("vec", async (t) => {
182+
const vec = [1, 2, 3];
183+
t.deepEqual((await contract.vec({ vec })).result, vec);
184+
});
158185

159-
test('tuple', async t => {
160-
const tuple = ['hello', 1] as const
161-
t.deepEqual((await contract.tuple({ tuple })).result, tuple)
162-
})
186+
test("tuple", async (t) => {
187+
const tuple = ["hello", 1] as const;
188+
t.deepEqual((await contract.tuple({ tuple })).result, tuple);
189+
});
163190

164-
test('option', async t => {
191+
test("option", async (t) => {
165192
// this makes sense
166-
t.deepEqual((await contract.option({ option: 1 })).result, 1)
193+
t.deepEqual((await contract.option({ option: 1 })).result, 1);
167194

168195
// this passes but shouldn't
169-
t.deepEqual((await contract.option({ option: undefined })).result, undefined)
196+
t.deepEqual((await contract.option({ option: undefined })).result, undefined);
170197

171198
// this is the behavior we probably want, but fails
172199
// t.deepEqual(await contract.option(), undefined) // typing and implementation require the object
173200
// t.deepEqual((await contract.option({})).result, undefined) // typing requires argument; implementation would be fine with this
174201
// t.deepEqual((await contract.option({ option: undefined })).result, undefined)
175-
})
202+
});
176203

177-
test('u256', async t => {
178-
t.is((await contract.u256({ u256: 1n })).result, 1n)
179-
})
204+
test("u256", async (t) => {
205+
t.is((await contract.u256({ u256: 1n })).result, 1n);
206+
});
180207

181-
test('i256', async t => {
182-
t.is((await contract.i256({ i256: -1n })).result, -1n)
183-
})
208+
test("i256", async (t) => {
209+
t.is((await contract.i256({ i256: -1n })).result, -1n);
210+
});
184211

185-
test('string', async t => {
186-
t.is((await contract.string({ string: 'hello' })).result, 'hello')
187-
})
212+
test("string", async (t) => {
213+
t.is((await contract.string({ string: "hello" })).result, "hello");
214+
});
188215

189-
test('tuple_strukt', async t => {
190-
const arg = [{ a: 0, b: true, c: 'hello' }, { tag: 'First', values: undefined }] as const
191-
const res = [{ a: 0, b: true, c: 'hello' }, { tag: 'First' }]
192-
t.deepEqual((await contract.tuple_strukt({ tuple_strukt: arg })).result, res)
193-
})
216+
test("tuple_strukt", async (t) => {
217+
const arg = [
218+
{ a: 0, b: true, c: "hello" },
219+
{ tag: "First", values: undefined },
220+
] as const;
221+
const res = [{ a: 0, b: true, c: "hello" }, { tag: "First" }];
222+
t.deepEqual((await contract.tuple_strukt({ tuple_strukt: arg })).result, res);
223+
});

0 commit comments

Comments
 (0)