Skip to content

Commit c6ad5fb

Browse files
authored
fix: updating ts deployer to use AlgorandClient; running deploy step in CI (#41)
* fix: updating ts deployer to use AlgorandClient; running deploy step in CI * chore: regen artifacts
1 parent 766dabd commit c6ad5fb

File tree

9 files changed

+98
-233
lines changed

9 files changed

+98
-233
lines changed

examples/generators/production_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../
55
export async function deploy() {
66
console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===')
77

8-
const algod = algokit.getAlgoClient()
9-
const indexer = algokit.getAlgoIndexerClient()
10-
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
11-
await algokit.ensureFunded(
12-
{
13-
accountToFund: deployer,
14-
minSpendingBalance: algokit.algos(2),
15-
minFundingIncrement: algokit.algos(2),
16-
},
17-
algod,
18-
)
19-
const appClient = new {{ contract_name.split('_')|map('capitalize')|join }}Client(
20-
{
21-
resolveBy: 'creatorAndName',
22-
findExistingUsing: indexer,
23-
sender: deployer,
24-
creatorAddress: deployer.addr,
25-
},
26-
algod,
27-
)
8+
const algorand = algokit.AlgorandClient.fromEnvironment()
9+
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
10+
11+
const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, {
12+
sender: deployer,
13+
creatorAddress: deployer.addr,
14+
})
2815

2916
const app = await appClient.deploy({
3017
onSchemaBreak: 'append',
3118
onUpdate: 'append',
3219
})
3320

34-
3521
// If app was just created fund the app account
3622
if (['create', 'replace'].includes(app.operationPerformed)) {
37-
algokit.transferAlgos(
38-
{
39-
amount: algokit.algos(1),
40-
from: deployer,
41-
to: app.appAddress,
42-
},
43-
algod,
44-
)
23+
await algorand.send.payment({
24+
amount: algokit.algos(1),
25+
sender: deployer.addr,
26+
receiver: app.appAddress,
27+
})
4528
}
4629

4730
const method = 'hello'

examples/generators/production_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,26 @@ import { CoolContractClient } from '../artifacts/cool_contract/CoolContractClien
55
export async function deploy() {
66
console.log('=== Deploying CoolContract ===')
77

8-
const algod = algokit.getAlgoClient()
9-
const indexer = algokit.getAlgoIndexerClient()
10-
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
11-
await algokit.ensureFunded(
12-
{
13-
accountToFund: deployer,
14-
minSpendingBalance: algokit.algos(2),
15-
minFundingIncrement: algokit.algos(2),
16-
},
17-
algod,
18-
)
19-
const appClient = new CoolContractClient(
20-
{
21-
resolveBy: 'creatorAndName',
22-
findExistingUsing: indexer,
23-
sender: deployer,
24-
creatorAddress: deployer.addr,
25-
},
26-
algod,
27-
)
8+
const algorand = algokit.AlgorandClient.fromEnvironment()
9+
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
10+
11+
const appClient = algorand.client.getTypedAppClientByCreatorAndName(CoolContractClient, {
12+
sender: deployer,
13+
creatorAddress: deployer.addr,
14+
})
2815

2916
const app = await appClient.deploy({
3017
onSchemaBreak: 'append',
3118
onUpdate: 'append',
3219
})
3320

34-
3521
// If app was just created fund the app account
3622
if (['create', 'replace'].includes(app.operationPerformed)) {
37-
algokit.transferAlgos(
38-
{
39-
amount: algokit.algos(1),
40-
from: deployer,
41-
to: app.appAddress,
42-
},
43-
algod,
44-
)
23+
await algorand.send.payment({
24+
amount: algokit.algos(1),
25+
sender: deployer.addr,
26+
receiver: app.appAddress,
27+
})
4528
}
4629

4730
const method = 'hello'

examples/generators/production_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,26 @@ import { HelloWorldClient } from '../artifacts/hello_world/HelloWorldClient'
55
export async function deploy() {
66
console.log('=== Deploying HelloWorld ===')
77

8-
const algod = algokit.getAlgoClient()
9-
const indexer = algokit.getAlgoIndexerClient()
10-
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
11-
await algokit.ensureFunded(
12-
{
13-
accountToFund: deployer,
14-
minSpendingBalance: algokit.algos(2),
15-
minFundingIncrement: algokit.algos(2),
16-
},
17-
algod,
18-
)
19-
const appClient = new HelloWorldClient(
20-
{
21-
resolveBy: 'creatorAndName',
22-
findExistingUsing: indexer,
23-
sender: deployer,
24-
creatorAddress: deployer.addr,
25-
},
26-
algod,
27-
)
8+
const algorand = algokit.AlgorandClient.fromEnvironment()
9+
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
10+
11+
const appClient = algorand.client.getTypedAppClientByCreatorAndName(HelloWorldClient, {
12+
sender: deployer,
13+
creatorAddress: deployer.addr,
14+
})
2815

2916
const app = await appClient.deploy({
3017
onSchemaBreak: 'append',
3118
onUpdate: 'append',
3219
})
3320

34-
3521
// If app was just created fund the app account
3622
if (['create', 'replace'].includes(app.operationPerformed)) {
37-
algokit.transferAlgos(
38-
{
39-
amount: algokit.algos(1),
40-
from: deployer,
41-
to: app.appAddress,
42-
},
43-
algod,
44-
)
23+
await algorand.send.payment({
24+
amount: algokit.algos(1),
25+
sender: deployer.addr,
26+
receiver: app.appAddress,
27+
})
4528
}
4629

4730
const method = 'hello'

examples/generators/starter_python_smart_contract_typescript/.algokit/generators/create_contract/smart_contracts/{{ contract_name }}/deploy-config.ts.j2

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../
55
export async function deploy() {
66
console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===')
77

8-
const algod = algokit.getAlgoClient()
9-
const indexer = algokit.getAlgoIndexerClient()
10-
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
11-
await algokit.ensureFunded(
12-
{
13-
accountToFund: deployer,
14-
minSpendingBalance: algokit.algos(2),
15-
minFundingIncrement: algokit.algos(2),
16-
},
17-
algod,
18-
)
19-
const appClient = new {{ contract_name.split('_')|map('capitalize')|join }}Client(
20-
{
21-
resolveBy: 'creatorAndName',
22-
findExistingUsing: indexer,
23-
sender: deployer,
24-
creatorAddress: deployer.addr,
25-
},
26-
algod,
27-
)
8+
const algorand = algokit.AlgorandClient.fromEnvironment()
9+
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
10+
11+
const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, {
12+
sender: deployer,
13+
creatorAddress: deployer.addr,
14+
})
2815

2916
const app = await appClient.deploy({
3017
onSchemaBreak: 'append',
3118
onUpdate: 'append',
3219
})
3320

34-
3521
// If app was just created fund the app account
3622
if (['create', 'replace'].includes(app.operationPerformed)) {
37-
algokit.transferAlgos(
38-
{
39-
amount: algokit.algos(1),
40-
from: deployer,
41-
to: app.appAddress,
42-
},
43-
algod,
44-
)
23+
await algorand.send.payment({
24+
amount: algokit.algos(1),
25+
sender: deployer.addr,
26+
receiver: app.appAddress,
27+
})
4528
}
4629

4730
const method = 'hello'

examples/generators/starter_python_smart_contract_typescript/smart_contracts/cool_contract/deploy-config.ts

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,26 @@ import { CoolContractClient } from '../artifacts/cool_contract/CoolContractClien
55
export async function deploy() {
66
console.log('=== Deploying CoolContract ===')
77

8-
const algod = algokit.getAlgoClient()
9-
const indexer = algokit.getAlgoIndexerClient()
10-
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
11-
await algokit.ensureFunded(
12-
{
13-
accountToFund: deployer,
14-
minSpendingBalance: algokit.algos(2),
15-
minFundingIncrement: algokit.algos(2),
16-
},
17-
algod,
18-
)
19-
const appClient = new CoolContractClient(
20-
{
21-
resolveBy: 'creatorAndName',
22-
findExistingUsing: indexer,
23-
sender: deployer,
24-
creatorAddress: deployer.addr,
25-
},
26-
algod,
27-
)
8+
const algorand = algokit.AlgorandClient.fromEnvironment()
9+
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
10+
11+
const appClient = algorand.client.getTypedAppClientByCreatorAndName(CoolContractClient, {
12+
sender: deployer,
13+
creatorAddress: deployer.addr,
14+
})
2815

2916
const app = await appClient.deploy({
3017
onSchemaBreak: 'append',
3118
onUpdate: 'append',
3219
})
3320

34-
3521
// If app was just created fund the app account
3622
if (['create', 'replace'].includes(app.operationPerformed)) {
37-
algokit.transferAlgos(
38-
{
39-
amount: algokit.algos(1),
40-
from: deployer,
41-
to: app.appAddress,
42-
},
43-
algod,
44-
)
23+
await algorand.send.payment({
24+
amount: algokit.algos(1),
25+
sender: deployer.addr,
26+
receiver: app.appAddress,
27+
})
4528
}
4629

4730
const method = 'hello'

examples/generators/starter_python_smart_contract_typescript/smart_contracts/hello_world/deploy-config.ts

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,26 @@ import { HelloWorldClient } from '../artifacts/hello_world/HelloWorldClient'
55
export async function deploy() {
66
console.log('=== Deploying HelloWorld ===')
77

8-
const algod = algokit.getAlgoClient()
9-
const indexer = algokit.getAlgoIndexerClient()
10-
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
11-
await algokit.ensureFunded(
12-
{
13-
accountToFund: deployer,
14-
minSpendingBalance: algokit.algos(2),
15-
minFundingIncrement: algokit.algos(2),
16-
},
17-
algod,
18-
)
19-
const appClient = new HelloWorldClient(
20-
{
21-
resolveBy: 'creatorAndName',
22-
findExistingUsing: indexer,
23-
sender: deployer,
24-
creatorAddress: deployer.addr,
25-
},
26-
algod,
27-
)
8+
const algorand = algokit.AlgorandClient.fromEnvironment()
9+
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
10+
11+
const appClient = algorand.client.getTypedAppClientByCreatorAndName(HelloWorldClient, {
12+
sender: deployer,
13+
creatorAddress: deployer.addr,
14+
})
2815

2916
const app = await appClient.deploy({
3017
onSchemaBreak: 'append',
3118
onUpdate: 'append',
3219
})
3320

34-
3521
// If app was just created fund the app account
3622
if (['create', 'replace'].includes(app.operationPerformed)) {
37-
algokit.transferAlgos(
38-
{
39-
amount: algokit.algos(1),
40-
from: deployer,
41-
to: app.appAddress,
42-
},
43-
algod,
44-
)
23+
await algorand.send.payment({
24+
amount: algokit.algos(1),
25+
sender: deployer.addr,
26+
receiver: app.appAddress,
27+
})
4528
}
4629

4730
const method = 'hello'

template_content/.algokit/generators/create_contract/smart_contracts/{% raw %}{{ contract_name }}{% endraw %}/{% if deployment_language == 'typescript' %}deploy-config.ts.j2{% endif %}

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../
55
export async function deploy() {
66
console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===')
77

8-
const algod = algokit.getAlgoClient()
9-
const indexer = algokit.getAlgoIndexerClient()
10-
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
11-
await algokit.ensureFunded(
12-
{
13-
accountToFund: deployer,
14-
minSpendingBalance: algokit.algos(2),
15-
minFundingIncrement: algokit.algos(2),
16-
},
17-
algod,
18-
)
19-
const appClient = new {{ contract_name.split('_')|map('capitalize')|join }}Client(
20-
{
21-
resolveBy: 'creatorAndName',
22-
findExistingUsing: indexer,
23-
sender: deployer,
24-
creatorAddress: deployer.addr,
25-
},
26-
algod,
27-
)
8+
const algorand = algokit.AlgorandClient.fromEnvironment()
9+
const deployer = await algorand.account.fromEnvironment('DEPLOYER')
10+
11+
const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, {
12+
sender: deployer,
13+
creatorAddress: deployer.addr,
14+
})
2815

2916
const app = await appClient.deploy({
3017
onSchemaBreak: 'append',
3118
onUpdate: 'append',
3219
})
3320

34-
3521
// If app was just created fund the app account
3622
if (['create', 'replace'].includes(app.operationPerformed)) {
37-
algokit.transferAlgos(
38-
{
39-
amount: algokit.algos(1),
40-
from: deployer,
41-
to: app.appAddress,
42-
},
43-
algod,
44-
)
23+
await algorand.send.payment({
24+
amount: algokit.algos(1),
25+
sender: deployer.addr,
26+
receiver: app.appAddress,
27+
})
4528
}
4629

4730
const method = 'hello'

0 commit comments

Comments
 (0)