Skip to content

Update template content #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { Contract } from '@algorandfoundation/algorand-typescript'

export class HelloWorld extends Contract {
public hello(name: string): string {
return `${this.getHello()} ${name}`
}

private getHello() {
return 'Hello'
return `Hello, ${name}`
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ describe('HelloWorld contract', () => {
})
registerDebugEventHandlers()
})
beforeEach(localnet.beforeEach)
beforeEach(localnet.newScope)

const deploy = async (account: Address) => {
const factory = localnet.algorand.client.getTypedAppFactory(HelloWorldFactory, {
defaultSender: account,
})

const { appClient } = await factory.deploy({ onUpdate: 'append', onSchemaBreak: 'append' })
const { appClient } = await factory.deploy({
onUpdate: 'append',
onSchemaBreak: 'append',
})
return { client: appClient }
}

Expand All @@ -31,7 +34,7 @@ describe('HelloWorld contract', () => {

const result = await client.send.hello({ args: { name: 'World' } })

expect(result.return).toBe('Hello World')
expect(result.return).toBe('Hello, World')
})

test('simulate says hello with correct budget consumed', async () => {
Expand All @@ -43,8 +46,8 @@ describe('HelloWorld contract', () => {
.hello({ args: { name: 'Jane' } })
.simulate()

expect(result.returns[0]).toBe('Hello World')
expect(result.returns[1]).toBe('Hello Jane')
expect(result.returns[0]).toBe('Hello, World')
expect(result.returns[1]).toBe('Hello, Jane')
expect(result.simulateResponse.txnGroups[0].appBudgetConsumed).toBeLessThan(100)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ describe('HelloWorld contract', () => {

const result = contract.hello('Sally')

expect(result).toBe('Hello Sally')
expect(result).toBe('Hello, Sally')
})
})
8 changes: 2 additions & 6 deletions examples/starter/smart_contracts/hello_world/contract.algo.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Contract } from '@algorandfoundation/algorand-typescript'

export class HelloWorld extends Contract {
public hello(name: string): string {
return `${this.getHello()} ${name}`
}

private getHello() {
return 'Hello'
hello(name: string): string {
return `Hello, ${name}`
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Contract } from '@algorandfoundation/algorand-typescript'

export class {{ contract_name.split('_')|map('capitalize')|join }} extends Contract {
public hello(name: string): string {
return `${this.getHello()} ${name}`
}

private getHello() {
return 'Hello'
{% if preset_name != 'starter' %}public {% endif %}hello(name: string): string {
return `Hello, ${name}`
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('{{ contract_name.split('_')|map('capitalize')|join }} contract', () =>
// traceAll: true,
})
})
beforeEach(localnet.beforeEach)
beforeEach(localnet.newScope)

const deploy = async (account: Address) => {
const factory = localnet.algorand.client.getTypedAppFactory({{ contract_name.split('_')|map('capitalize')|join }}Factory, {
Expand Down
7 changes: 0 additions & 7 deletions template_content/.editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion template_content/.npmrc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Contract } from '@algorandfoundation/algorand-typescript'

export class {{ contract_name.split('_')|map('capitalize')|join }} extends Contract {
public hello(name: string): string {
return `${this.getHello()} ${name}`
}

private getHello() {
return 'Hello'
{% if preset_name != 'starter' %}public {% endif %}hello(name: string): string {
return `Hello, ${name}`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears the template, even for the starter version, does not have semicolons, so that's what we want. Just want to test that this works once a project is init from the starter template. If not, it may require adding prettier config to the starter template.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - I formatted it according to the prettier config in the production template. I don't believe the starter template ships with eslint/prettier, pretty sure that's a setting passed in from the algokit CLI? If changes are needed here, let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can test the output of this template if you run algokit -v init --name playground --no-git --UNSAFE-SECURITY-accept-template-url --template-url . --template-url-ref HEAD --no-bootstrap from the root of this repo btw. :)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ describe('{{ contract_name.split('_')|map('capitalize')|join }} contract', () =>
})
registerDebugEventHandlers()
})
beforeEach(localnet.beforeEach)
beforeEach(localnet.newScope)

const deploy = async (account: Address) => {
const factory = localnet.algorand.client.getTypedAppFactory({{ contract_name.split('_')|map('capitalize')|join }}Factory, {
defaultSender: account,
})

const { appClient } = await factory.deploy({ onUpdate: 'append', onSchemaBreak: 'append' })
const { appClient } = await factory.deploy({
onUpdate: 'append',
onSchemaBreak: 'append',
})
return { client: appClient }
}

Expand All @@ -31,7 +34,7 @@ describe('{{ contract_name.split('_')|map('capitalize')|join }} contract', () =>

const result = await client.send.hello({ args: { name: 'World' } })

expect(result.return).toBe('Hello World')
expect(result.return).toBe('Hello, World')
})

test('simulate says hello with correct budget consumed', async () => {
Expand All @@ -43,8 +46,8 @@ describe('{{ contract_name.split('_')|map('capitalize')|join }} contract', () =>
.hello({ args: { name: 'Jane' } })
.simulate()

expect(result.returns[0]).toBe('Hello World')
expect(result.returns[1]).toBe('Hello Jane')
expect(result.returns[0]).toBe('Hello, World')
expect(result.returns[1]).toBe('Hello, Jane')
expect(result.simulateResponse.txnGroups[0].appBudgetConsumed).toBeLessThan(100)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ describe('{{ contract_name.split('_')|map('capitalize')|join }} contract', () =>

const result = contract.hello('Sally')

expect(result).toBe('Hello Sally')
expect(result).toBe('Hello, Sally')
})
})

This file was deleted.

File renamed without changes.