Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
27ebf04
Before running with prettier
CoveMB Feb 21, 2025
7c7828e
After running with prettier
CoveMB Feb 21, 2025
ce5fcd3
Add consistent-type-imports rule
CoveMB Feb 21, 2025
3cd0b59
Add lint step in ci action
CoveMB Feb 21, 2025
31f0c78
resolve prettier conflict
CoveMB Feb 21, 2025
365421b
After running with prettier
CoveMB Feb 21, 2025
cedaeaa
resolve prettier conflict
CoveMB Feb 21, 2025
98bd8af
Add lint step in ci action
CoveMB Feb 21, 2025
a9098d0
resolve prettier conflict
CoveMB Feb 21, 2025
6e9df26
resolve prettier conflict
CoveMB Feb 21, 2025
574a739
Remove .vscode directory from Git tracking
CoveMB Feb 21, 2025
c0e9002
move linter action in it's own job
CoveMB Feb 21, 2025
86c65dc
add lint note in readme
CoveMB Feb 21, 2025
a1111d3
Update .github/workflows/test.yml
CoveMB Feb 21, 2025
abbd5a4
Merge remote-tracking branch 'upstream/master'
CoveMB Feb 21, 2025
beffa34
Merge branch 'master' into master
ericglau Feb 21, 2025
d6bec2a
lint script files
CoveMB Feb 21, 2025
315b775
Merge branch 'master' of github.com:CoveMB/contracts-wizard
CoveMB Feb 21, 2025
6ed6e4f
Merge remote-tracking branch 'upstream/master'
CoveMB Feb 24, 2025
ea90cd1
Merge remote-tracking branch 'upstream/master'
CoveMB Feb 28, 2025
abf687a
Merge remote-tracking branch 'upstream/master'
CoveMB Mar 4, 2025
426b62d
Merge remote-tracking branch 'upstream/master'
CoveMB Mar 20, 2025
ea25cc1
Merge remote-tracking branch 'upstream/master'
CoveMB Mar 20, 2025
0911f87
Merge remote-tracking branch 'upstream/master'
CoveMB Mar 25, 2025
4914083
Merge remote-tracking branch 'upstream/master'
CoveMB Mar 27, 2025
5ce527f
Merge remote-tracking branch 'upstream/master'
CoveMB Apr 4, 2025
03a32fc
Merge remote-tracking branch 'upstream/master'
CoveMB Apr 7, 2025
b3c0347
Merge remote-tracking branch 'upstream/master'
CoveMB Apr 12, 2025
0a52a65
Merge remote-tracking branch 'upstream/master'
CoveMB May 13, 2025
9e74342
Merge remote-tracking branch 'upstream/master'
CoveMB May 19, 2025
d727f51
Merge remote-tracking branch 'upstream/master'
CoveMB May 21, 2025
60fb18f
Merge remote-tracking branch 'upstream/master'
CoveMB May 26, 2025
cbb7631
Merge remote-tracking branch 'upstream/master'
CoveMB May 27, 2025
0f1267f
Merge remote-tracking branch 'upstream/master'
CoveMB Jun 5, 2025
427f4b6
Add securityContact to contract model, print function, ai agent and ui
CoveMB Jun 6, 2025
0fa0cba
update tests snapshots
CoveMB Jun 6, 2025
c78d62f
Add changeset
CoveMB Jun 6, 2025
a7e69cc
Update packages/core/stellar/src/print.ts
CoveMB Jun 6, 2025
22b1f15
move security documentation after SPDX-License-Identifier
CoveMB Jun 10, 2025
80183c7
Merge branch 'stellar-add-security-contract-field' of github.com:Cove…
CoveMB Jun 10, 2025
9288291
move security documentation after SPDX-License-Identifier
CoveMB Jun 10, 2025
5b1b06b
move security documentation after SPDX-License-Identifier
CoveMB Jun 10, 2025
9a480ee
Merge remote-tracking branch 'upstream/master' into stellar-add-secur…
CoveMB Jun 13, 2025
e112b2a
Use simple documentation
CoveMB Jun 13, 2025
c510ada
remove unsued variable
CoveMB Jun 16, 2025
1b13223
Resove conflicts
CoveMB Jun 17, 2025
0e67560
Resove conflicts
CoveMB Jun 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/busy-banks-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openzeppelin/wizard-stellar': patch
---

Add security contact in contract info
19 changes: 19 additions & 0 deletions packages/core/stellar/src/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,22 @@ test('contract with sorted use clauses', t => {
Foo.addUseClause('another::library', 'self', { alias: 'custom1' });
t.snapshot(printContract(Foo));
});

test('contract with documentation', t => {
const Foo = new ContractBuilder('Foo');
Foo.addDocumentation('Some documentation');
t.snapshot(printContract(Foo));
});

test('contract with security info', t => {
const Foo = new ContractBuilder('Foo');
Foo.addSecurityTag('[email protected]');
t.snapshot(printContract(Foo));
});

test('contract with security info and documentation', t => {
const Foo = new ContractBuilder('Foo');
Foo.addSecurityTag('[email protected]');
Foo.addDocumentation('Some documentation');
t.snapshot(printContract(Foo));
});
48 changes: 48 additions & 0 deletions packages/core/stellar/src/contract.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,51 @@ Generated by [AVA](https://avajs.dev).
#[contract]␊
pub struct Foo;␊
`

## contract with documentation

> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.2.0␊
//! Some documentation␊
#![no_std]␊
#[contract]␊
pub struct Foo;␊
`

## contract with security info

> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.2.0␊
//! # Security␊
//!␊
//! For security issues, please contact: [email protected]
#![no_std]␊
#[contract]␊
pub struct Foo;␊
`

## contract with security info and documentation

> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Stellar Soroban Contracts ^0.2.0␊
//! Some documentation␊
//! # Security␊
//!␊
//! For security issues, please contact: [email protected]
#![no_std]␊
#[contract]␊
pub struct Foo;␊
`
Binary file modified packages/core/stellar/src/contract.test.ts.snap
Binary file not shown.
13 changes: 13 additions & 0 deletions packages/core/stellar/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { toIdentifier } from './utils/convert-strings';

export interface Contract {
license: string;
securityContact: string;
documentations: string[];
name: string;
useClauses: UseClause[];
constructorCode: string[];
Expand Down Expand Up @@ -72,8 +74,11 @@ export interface Argument {
export class ContractBuilder implements Contract {
readonly name: string;
license = 'MIT';
securityContact = '';
ownable = false;

readonly documentations: string[] = [];

readonly constructorArgs: Argument[] = [];
readonly constructorCode: string[] = [];

Expand Down Expand Up @@ -250,4 +255,12 @@ export class ContractBuilder implements Contract {
addDerives(derive: string): void {
this.derivesSet.add(derive);
}

addDocumentation(description: string) {
this.documentations.push(description);
}

addSecurityTag(securityContact: string) {
this.securityContact = securityContact;
}
}
10 changes: 10 additions & 0 deletions packages/core/stellar/src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export function printContract(contract: Contract): string {
[
`// SPDX-License-Identifier: ${contract.license}`,
`// Compatible with OpenZeppelin Stellar Soroban Contracts ${compatibleContractsSemver}`,
...(contract.documentations.length ? ['', ...printDocumentations(contract.documentations)] : []),
...(contract.securityContact ? ['', ...printSecurityTag(contract.securityContact)] : []),
...createLevelAttributes,
],
spaceBetween(
Expand Down Expand Up @@ -360,3 +362,11 @@ function printArgument(arg: Argument): string {
return `${arg.name}`;
}
}

function printDocumentations(documentations: string[]): string[] {
return documentations.map(documentation => `//! ${documentation}`);
}

function printSecurityTag(securityContact: string) {
return ['//! # Security', '//!', `//! For security issues, please contact: ${securityContact}`];
}
9 changes: 8 additions & 1 deletion packages/core/stellar/src/set-info.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import type { ContractBuilder } from './contract';

export const TAG_SECURITY_CONTACT = `@custom:security-contact`;

export const infoOptions = [{}, { license: 'WTFPL' }] as const;

export const defaults: Info = { license: 'MIT' };

export type Info = {
license?: string;
securityContact?: string;
};

export function setInfo(c: ContractBuilder, info: Info): void {
const { license } = info;
const { securityContact, license } = info;

if (securityContact) {
c.addSecurityTag(securityContact);
}

if (license) {
c.license = license;
Expand Down
Loading
Loading