Skip to content

Commit 537620a

Browse files
CoveMBericglaubrozorec
authored
Download stellar scaffold (#562)
Co-authored-by: Eric Lau <[email protected]> Co-authored-by: Boyan Barakov <[email protected]>
1 parent 849652d commit 537620a

File tree

12 files changed

+11523
-3
lines changed

12 files changed

+11523
-3
lines changed

.github/workflows/test.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
run: yarn type:check:api
3232

3333
build:
34+
timeout-minutes: 90
3435
strategy:
3536
matrix:
3637
package:
@@ -44,9 +45,76 @@ jobs:
4445
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
4546
- name: Set up environment
4647
uses: ./.github/actions/setup
48+
49+
# ----------------------------
50+
# Solidity setup
4751
- name: Install Foundry
4852
if: matrix.package == 'solidity'
4953
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de #v1.4.0
54+
55+
# ----------------------------
56+
# Stellar setup
57+
58+
- name: Free up disk space
59+
if: matrix.package == 'stellar'
60+
run: |
61+
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android
62+
df -h
63+
64+
# - name: Get scaffold-stellar latest commit SHA
65+
# if: matrix.package == 'stellar'
66+
# id: get-scaffold-sha
67+
# run: |
68+
# echo "sha=$(git ls-remote https://github.com/ahalabs/scaffold-stellar HEAD | cut -f1)" >> $GITHUB_OUTPUT
69+
70+
# - name: Cache Scaffold CLIs
71+
# if: matrix.package == 'stellar'
72+
# uses: actions/cache@v4
73+
# with:
74+
# path: |
75+
# ~/.cargo/bin/
76+
# ~/.cargo/registry/index/
77+
# ~/.cargo/registry/cache/
78+
# ~/.cargo/git/db/
79+
# key: cargo-scaffold-${{ matrix.package }}-${{ steps.get-scaffold-sha.outputs.sha }}
80+
# restore-keys: |
81+
# cargo-scaffold-${{ matrix.package }}-
82+
# cargo-scaffold-
83+
# cargo-scaffold-
84+
85+
- name: Set up Rust
86+
if: matrix.package == 'stellar'
87+
uses: actions-rs/toolchain@v1
88+
with:
89+
toolchain: 1.86.0
90+
profile: minimal
91+
override: true
92+
- name: Add wasm32v1 target
93+
if: matrix.package == 'stellar'
94+
run: |
95+
if ! rustup target list --installed | grep -q wasm32v1-none; then
96+
rustup target add wasm32v1-none
97+
fi
98+
99+
- name: Set up Stellar CLI
100+
if: matrix.package == 'stellar'
101+
uses: stellar/[email protected]
102+
103+
- name: Install Scaffold & Registry CLIs
104+
if: matrix.package == 'stellar'
105+
run: |
106+
rebuildIfNotFoundInCache() {
107+
local binary_name="$1"
108+
109+
if ! [ -x "$HOME/.cargo/bin/$binary_name" ]; then
110+
cargo install --git "https://github.com/ahalabs/scaffold-stellar" "$binary_name"
111+
fi
112+
}
113+
114+
rebuildIfNotFoundInCache stellar-scaffold-cli
115+
rebuildIfNotFoundInCache stellar-registry-cli
116+
117+
# ----------------------------
50118
- name: Compile TypeScript
51119
run: yarn tsc
52120
working-directory: packages/core/${{matrix.package}}

packages/core/stellar/src/print.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,21 @@ const DEFAULT_SECTION = '1. with no section';
99
const STANDALONE_IMPORTS_GROUP = 'Standalone Imports';
1010
const MAX_USE_CLAUSE_LINE_LENGTH = 90;
1111
const TAB = ' ';
12+
export const createLevelAttributes = [`#![no_std]`];
13+
14+
export const removeCreateLevelAttributes = (printedContract: string) =>
15+
createLevelAttributes.reduce(
16+
(cleanedPrintedContract, createLevelAttribute) => cleanedPrintedContract.replace(createLevelAttribute, ''),
17+
printedContract,
18+
);
1219

1320
export function printContract(contract: Contract): string {
1421
return formatLines(
1522
...spaceBetween(
1623
[
1724
`// SPDX-License-Identifier: ${contract.license}`,
1825
`// Compatible with OpenZeppelin Stellar Soroban Contracts ${compatibleContractsSemver}`,
19-
`#![no_std]`,
26+
...createLevelAttributes,
2027
],
2128
spaceBetween(
2229
printUseClauses(contract),

packages/core/stellar/src/utils/version.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ export const contractsVersionTag = `v${contractsVersion}`;
88
* Semantic version string representing of the minimum compatible version of Contracts to display in output.
99
*/
1010
export const compatibleContractsSemver = '^0.2.0';
11+
12+
/**
13+
* The Soroban version for which compilation and testing have passing tests
14+
*/
15+
export const compatibleSorobanVersion = '22.0.8';

0 commit comments

Comments
 (0)