Skip to content

Commit

Permalink
update build and contract files, move contract to source
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol1696 committed Oct 2, 2024
1 parent 296c824 commit 6c19025
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 151 deletions.
2 changes: 1 addition & 1 deletion __tests__/simple-state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('JSD tests', () => {

it('instantiate contract', async () => {
// Read contract code from external file
const contractPath = path.join(__dirname, '../contracts/simple-state.js');
const contractPath = path.join(__dirname, '../contracts/contract1.js');
contractCode = fs.readFileSync(contractPath, 'utf8');

const fee = {
Expand Down
2 changes: 1 addition & 1 deletion configs/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ chains:
- id: jsd
name: custom
numValidators: 1
image: ghcr.io/cosmology-tech/jsd:latest
image: ghcr.io/cosmology-tech/jsd:latest@sha256:298d4b464039d8be430588960573f72a1dbdae2181cc562369952ab3ca220806
home: /root/.jsd
binary: jsdd
prefix: cosmos
Expand Down
2 changes: 1 addition & 1 deletion configs/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ chains:
- id: jsd
name: custom
numValidators: 1
image: ghcr.io/cosmology-tech/jsd:latest
image: ghcr.io/cosmology-tech/jsd:latest@sha256:298d4b464039d8be430588960573f72a1dbdae2181cc562369952ab3ca220806
home: /root/.jsd
binary: jsdd
prefix: cosmos
Expand Down
28 changes: 28 additions & 0 deletions contracts/contract1.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions contracts/contract1.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,24 @@
"starship:ci": "starship --config configs/ci.yaml"
},
"devDependencies": {
"@types/node": "^22.7.4",
"@interweb/build": "^0.0.5",
"@starship-ci/cli": "^2.10.1",
"@types/jest": "^29.5.11",
"@types/node": "^22.7.4",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unused-imports": "^3.0.0",
"eslint": "^8.56.0",
"jest": "^29.6.2",
"jsdjs": "1.5.0",
"prettier": "^3.0.2",
"rimraf": "4.4.1",
"starshipjs": "^2.4.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"typescript": "^5.1.6",
"@starship-ci/cli": "^2.10.1",
"starshipjs": "^2.4.1",
"jsdjs": "1.5.0"
"typescript": "^5.1.6"
},
"keywords": []
}
}
6 changes: 3 additions & 3 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ const outputDir = join(root, 'contracts');
const srcDir = join(root, 'src');

async function main() {
const outfile = join(outputDir, 'bundle.js');
const outfile = join(outputDir, 'contract1.js');

const options: Partial<InterwebBuildOptions> = {
entryPoints: [join(srcDir, 'contract1/index.ts')],
outfile,
external: ['otherpackage', '~somepackage']
external: ['otherpackage', '~somepackage'],
};

try {
Expand All @@ -22,4 +22,4 @@ async function main() {
}
}

main().catch(console.error);
main().catch(console.error);
12 changes: 8 additions & 4 deletions contracts/simple-state.js → src/contract1/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
export function reset(state) {
interface MyState {
value: number;
}

export function reset(state: MyState) {
const newValue = 0;
state.set('value', 0);
return newValue
}
export function inc(state, {x}) {
export function inc(state: MyState, {x}) {
const oldValue = state.get('value') ?? 0;
const newValue = oldValue + x;
state.set('value', newValue);
return newValue
}
export function dec(state, {x}) {
export function dec(state: MyState, {x}) {
const oldValue = state.get('value') ?? 0;
const newValue = oldValue - x;
state.set('value', newValue);
return newValue
}

export function read(state) {
export function read(state: MyState) {
return state.get('value');
}
Loading

0 comments on commit 6c19025

Please sign in to comment.