@openzeppelin/wizard-stellar 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/common-options.js +2 -4
- package/dist/common-options.js.map +1 -1
- package/dist/contract.d.ts +9 -3
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +13 -10
- package/dist/contract.js.map +1 -1
- package/dist/fungible.d.ts +1 -1
- package/dist/fungible.js +8 -10
- package/dist/fungible.js.map +1 -1
- package/dist/generate/alternatives.js +1 -1
- package/dist/generate/alternatives.js.map +1 -1
- package/dist/generate/non-fungible.d.ts.map +1 -1
- package/dist/generate/non-fungible.js +1 -0
- package/dist/generate/non-fungible.js.map +1 -1
- package/dist/non-fungible.d.ts +1 -0
- package/dist/non-fungible.d.ts.map +1 -1
- package/dist/non-fungible.js +12 -11
- package/dist/non-fungible.js.map +1 -1
- package/dist/print.d.ts.map +1 -1
- package/dist/print.js +6 -10
- package/dist/print.js.map +1 -1
- package/dist/set-info.d.ts +1 -2
- package/dist/set-info.d.ts.map +1 -1
- package/dist/set-info.js +5 -9
- package/dist/set-info.js.map +1 -1
- package/dist/stablecoin.js +3 -4
- package/dist/stablecoin.js.map +1 -1
- package/dist/utils/compile-test.d.ts +12 -0
- package/dist/utils/compile-test.d.ts.map +1 -0
- package/dist/utils/compile-test.js +49 -0
- package/dist/utils/compile-test.js.map +1 -0
- package/dist/utils/define-functions.js +4 -7
- package/dist/utils/define-functions.js.map +1 -1
- package/dist/utils/zip-test.d.ts +9 -0
- package/dist/utils/zip-test.d.ts.map +1 -0
- package/dist/utils/zip-test.js +43 -0
- package/dist/utils/zip-test.js.map +1 -0
- package/dist/zip-rust.d.ts.map +1 -1
- package/dist/zip-rust.js +2 -16
- package/dist/zip-rust.js.map +1 -1
- package/dist/zip-scaffold.d.ts.map +1 -1
- package/dist/zip-shared.d.ts.map +1 -1
- package/dist/zip-shared.js +18 -1
- package/dist/zip-shared.js.map +1 -1
- package/package.json +1 -1
- package/src/contract.ts +11 -5
- package/src/fungible.ts +1 -1
- package/src/generate/non-fungible.ts +1 -0
- package/src/non-fungible.ts +6 -3
- package/src/print.ts +4 -3
- package/src/set-info.ts +3 -11
- package/src/utils/compile-test.ts +69 -0
- package/src/utils/zip-test.ts +55 -0
- package/src/zip-rust.ts +1 -17
- package/src/zip-shared.ts +17 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { JSZipObject } from 'jszip';
|
|
2
|
+
import type JSZip from 'jszip';
|
|
3
|
+
import type { ExecutionContext } from 'ava';
|
|
4
|
+
import { mkdir, writeFile } from 'fs/promises';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
|
|
7
|
+
const getItemString =
|
|
8
|
+
({ files }: JSZip) =>
|
|
9
|
+
async (key: string) => {
|
|
10
|
+
const obj = files[key];
|
|
11
|
+
if (obj === undefined) throw Error(`Item ${key} not found in zip`);
|
|
12
|
+
return await asString(obj);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const asString = async (item: JSZipObject) => Buffer.from(await item.async('arraybuffer')).toString();
|
|
16
|
+
|
|
17
|
+
export const snapshotZipContents = async (test: ExecutionContext, zip: JSZip, contentsPathToAsserts: string[]) => {
|
|
18
|
+
const itemStrings = await Promise.all(contentsPathToAsserts.map(getItemString(zip)));
|
|
19
|
+
test.snapshot(itemStrings);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const assertLayout = (test: ExecutionContext, zip: JSZip, expectedLayout: string[]) =>
|
|
23
|
+
test.deepEqual(
|
|
24
|
+
Object.values(zip.files)
|
|
25
|
+
.map(f => f.name)
|
|
26
|
+
.sort(),
|
|
27
|
+
expectedLayout.sort(),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const expandPathsFromFilesPaths = (filePaths: string[]): string[] =>
|
|
31
|
+
Array.from(
|
|
32
|
+
new Set(
|
|
33
|
+
filePaths.flatMap((filePath: string) => {
|
|
34
|
+
const parts = filePath.split('/');
|
|
35
|
+
|
|
36
|
+
if (parts.length === 1) return [filePath];
|
|
37
|
+
|
|
38
|
+
const folders = parts.slice(0, -1).map((_, idx) => parts.slice(0, idx + 1).join('/') + '/');
|
|
39
|
+
|
|
40
|
+
return [...folders, filePath];
|
|
41
|
+
}),
|
|
42
|
+
),
|
|
43
|
+
).sort();
|
|
44
|
+
|
|
45
|
+
export const extractPackage = async (zip: JSZip, folderPath: string) => {
|
|
46
|
+
const items = Object.values(Object.values(zip.files));
|
|
47
|
+
|
|
48
|
+
for (const item of items) {
|
|
49
|
+
if (item.dir) {
|
|
50
|
+
await mkdir(join(folderPath, item.name));
|
|
51
|
+
} else {
|
|
52
|
+
await writeFile(join(folderPath, item.name), await asString(item));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
package/src/zip-rust.ts
CHANGED
|
@@ -3,28 +3,12 @@ import type { GenericOptions } from './build-generic';
|
|
|
3
3
|
import type { Contract } from './contract';
|
|
4
4
|
import { printContract, removeCreateLevelAttributes } from './print';
|
|
5
5
|
import {
|
|
6
|
-
addDependenciesWith,
|
|
7
|
-
libDependencies,
|
|
8
6
|
contractOptionsToContractName,
|
|
9
7
|
createRustLibFile,
|
|
10
8
|
printContractCargo,
|
|
11
9
|
printRustNameTest,
|
|
10
|
+
workspaceCargo,
|
|
12
11
|
} from './zip-shared';
|
|
13
|
-
import { contractsVersion, compatibleSorobanVersion } from './utils/version';
|
|
14
|
-
|
|
15
|
-
const workspaceCargo = `[workspace]
|
|
16
|
-
resolver = "2"
|
|
17
|
-
members = ["contracts/*"]
|
|
18
|
-
|
|
19
|
-
[workspace.package]
|
|
20
|
-
authors = []
|
|
21
|
-
edition = "2021"
|
|
22
|
-
license = "Apache-2.0"
|
|
23
|
-
version = "0.0.1"
|
|
24
|
-
|
|
25
|
-
[workspace.dependencies]
|
|
26
|
-
${addDependenciesWith(`"${compatibleSorobanVersion}"`, ['soroban-sdk'])}${addDependenciesWith(`"=${contractsVersion}"`, [...libDependencies])}
|
|
27
|
-
`;
|
|
28
12
|
|
|
29
13
|
const readme = `\
|
|
30
14
|
# Sample Rust Contract Environment
|
package/src/zip-shared.ts
CHANGED
|
@@ -58,6 +58,9 @@ license.workspace = true
|
|
|
58
58
|
publish = false
|
|
59
59
|
version.workspace = true
|
|
60
60
|
|
|
61
|
+
[package.metadata.stellar]
|
|
62
|
+
cargo_inherit = true
|
|
63
|
+
|
|
61
64
|
[lib]
|
|
62
65
|
crate-type = ["cdylib"]
|
|
63
66
|
doctest = false
|
|
@@ -86,4 +89,18 @@ version = "0.0.1"
|
|
|
86
89
|
|
|
87
90
|
[workspace.dependencies]
|
|
88
91
|
${addDependenciesWith(`"${compatibleSorobanVersion}"`, ['soroban-sdk'])}${addDependenciesWith(`"=${contractsVersion}"`, [...libDependencies])}
|
|
92
|
+
|
|
93
|
+
[profile.release]
|
|
94
|
+
opt-level = "z"
|
|
95
|
+
overflow-checks = true
|
|
96
|
+
debug = 0
|
|
97
|
+
strip = "symbols"
|
|
98
|
+
debug-assertions = false
|
|
99
|
+
panic = "abort"
|
|
100
|
+
codegen-units = 1
|
|
101
|
+
lto = true
|
|
102
|
+
|
|
103
|
+
[profile.release-with-logs]
|
|
104
|
+
inherits = "release"
|
|
105
|
+
debug-assertions = true
|
|
89
106
|
`;
|