Skip to content

Commit

Permalink
fix: updating ts deployer to use AlgorandClient; running deploy step …
Browse files Browse the repository at this point in the history
…in CI (#41)

* fix: updating ts deployer to use AlgorandClient; running deploy step in CI

* chore: regen artifacts
  • Loading branch information
aorumbayev authored Aug 15, 2024
1 parent 766dabd commit c6ad5fb
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 233 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../
export async function deploy() {
console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===')

const algod = algokit.getAlgoClient()
const indexer = algokit.getAlgoIndexerClient()
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
await algokit.ensureFunded(
{
accountToFund: deployer,
minSpendingBalance: algokit.algos(2),
minFundingIncrement: algokit.algos(2),
},
algod,
)
const appClient = new {{ contract_name.split('_')|map('capitalize')|join }}Client(
{
resolveBy: 'creatorAndName',
findExistingUsing: indexer,
sender: deployer,
creatorAddress: deployer.addr,
},
algod,
)
const algorand = algokit.AlgorandClient.fromEnvironment()
const deployer = await algorand.account.fromEnvironment('DEPLOYER')

const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, {
sender: deployer,
creatorAddress: deployer.addr,
})

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


// If app was just created fund the app account
if (['create', 'replace'].includes(app.operationPerformed)) {
algokit.transferAlgos(
{
amount: algokit.algos(1),
from: deployer,
to: app.appAddress,
},
algod,
)
await algorand.send.payment({
amount: algokit.algos(1),
sender: deployer.addr,
receiver: app.appAddress,
})
}

const method = 'hello'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,26 @@ import { CoolContractClient } from '../artifacts/cool_contract/CoolContractClien
export async function deploy() {
console.log('=== Deploying CoolContract ===')

const algod = algokit.getAlgoClient()
const indexer = algokit.getAlgoIndexerClient()
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
await algokit.ensureFunded(
{
accountToFund: deployer,
minSpendingBalance: algokit.algos(2),
minFundingIncrement: algokit.algos(2),
},
algod,
)
const appClient = new CoolContractClient(
{
resolveBy: 'creatorAndName',
findExistingUsing: indexer,
sender: deployer,
creatorAddress: deployer.addr,
},
algod,
)
const algorand = algokit.AlgorandClient.fromEnvironment()
const deployer = await algorand.account.fromEnvironment('DEPLOYER')

const appClient = algorand.client.getTypedAppClientByCreatorAndName(CoolContractClient, {
sender: deployer,
creatorAddress: deployer.addr,
})

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


// If app was just created fund the app account
if (['create', 'replace'].includes(app.operationPerformed)) {
algokit.transferAlgos(
{
amount: algokit.algos(1),
from: deployer,
to: app.appAddress,
},
algod,
)
await algorand.send.payment({
amount: algokit.algos(1),
sender: deployer.addr,
receiver: app.appAddress,
})
}

const method = 'hello'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,26 @@ import { HelloWorldClient } from '../artifacts/hello_world/HelloWorldClient'
export async function deploy() {
console.log('=== Deploying HelloWorld ===')

const algod = algokit.getAlgoClient()
const indexer = algokit.getAlgoIndexerClient()
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
await algokit.ensureFunded(
{
accountToFund: deployer,
minSpendingBalance: algokit.algos(2),
minFundingIncrement: algokit.algos(2),
},
algod,
)
const appClient = new HelloWorldClient(
{
resolveBy: 'creatorAndName',
findExistingUsing: indexer,
sender: deployer,
creatorAddress: deployer.addr,
},
algod,
)
const algorand = algokit.AlgorandClient.fromEnvironment()
const deployer = await algorand.account.fromEnvironment('DEPLOYER')

const appClient = algorand.client.getTypedAppClientByCreatorAndName(HelloWorldClient, {
sender: deployer,
creatorAddress: deployer.addr,
})

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


// If app was just created fund the app account
if (['create', 'replace'].includes(app.operationPerformed)) {
algokit.transferAlgos(
{
amount: algokit.algos(1),
from: deployer,
to: app.appAddress,
},
algod,
)
await algorand.send.payment({
amount: algokit.algos(1),
sender: deployer.addr,
receiver: app.appAddress,
})
}

const method = 'hello'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../
export async function deploy() {
console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===')

const algod = algokit.getAlgoClient()
const indexer = algokit.getAlgoIndexerClient()
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
await algokit.ensureFunded(
{
accountToFund: deployer,
minSpendingBalance: algokit.algos(2),
minFundingIncrement: algokit.algos(2),
},
algod,
)
const appClient = new {{ contract_name.split('_')|map('capitalize')|join }}Client(
{
resolveBy: 'creatorAndName',
findExistingUsing: indexer,
sender: deployer,
creatorAddress: deployer.addr,
},
algod,
)
const algorand = algokit.AlgorandClient.fromEnvironment()
const deployer = await algorand.account.fromEnvironment('DEPLOYER')

const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, {
sender: deployer,
creatorAddress: deployer.addr,
})

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


// If app was just created fund the app account
if (['create', 'replace'].includes(app.operationPerformed)) {
algokit.transferAlgos(
{
amount: algokit.algos(1),
from: deployer,
to: app.appAddress,
},
algod,
)
await algorand.send.payment({
amount: algokit.algos(1),
sender: deployer.addr,
receiver: app.appAddress,
})
}

const method = 'hello'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,26 @@ import { CoolContractClient } from '../artifacts/cool_contract/CoolContractClien
export async function deploy() {
console.log('=== Deploying CoolContract ===')

const algod = algokit.getAlgoClient()
const indexer = algokit.getAlgoIndexerClient()
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
await algokit.ensureFunded(
{
accountToFund: deployer,
minSpendingBalance: algokit.algos(2),
minFundingIncrement: algokit.algos(2),
},
algod,
)
const appClient = new CoolContractClient(
{
resolveBy: 'creatorAndName',
findExistingUsing: indexer,
sender: deployer,
creatorAddress: deployer.addr,
},
algod,
)
const algorand = algokit.AlgorandClient.fromEnvironment()
const deployer = await algorand.account.fromEnvironment('DEPLOYER')

const appClient = algorand.client.getTypedAppClientByCreatorAndName(CoolContractClient, {
sender: deployer,
creatorAddress: deployer.addr,
})

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


// If app was just created fund the app account
if (['create', 'replace'].includes(app.operationPerformed)) {
algokit.transferAlgos(
{
amount: algokit.algos(1),
from: deployer,
to: app.appAddress,
},
algod,
)
await algorand.send.payment({
amount: algokit.algos(1),
sender: deployer.addr,
receiver: app.appAddress,
})
}

const method = 'hello'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,26 @@ import { HelloWorldClient } from '../artifacts/hello_world/HelloWorldClient'
export async function deploy() {
console.log('=== Deploying HelloWorld ===')

const algod = algokit.getAlgoClient()
const indexer = algokit.getAlgoIndexerClient()
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
await algokit.ensureFunded(
{
accountToFund: deployer,
minSpendingBalance: algokit.algos(2),
minFundingIncrement: algokit.algos(2),
},
algod,
)
const appClient = new HelloWorldClient(
{
resolveBy: 'creatorAndName',
findExistingUsing: indexer,
sender: deployer,
creatorAddress: deployer.addr,
},
algod,
)
const algorand = algokit.AlgorandClient.fromEnvironment()
const deployer = await algorand.account.fromEnvironment('DEPLOYER')

const appClient = algorand.client.getTypedAppClientByCreatorAndName(HelloWorldClient, {
sender: deployer,
creatorAddress: deployer.addr,
})

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


// If app was just created fund the app account
if (['create', 'replace'].includes(app.operationPerformed)) {
algokit.transferAlgos(
{
amount: algokit.algos(1),
from: deployer,
to: app.appAddress,
},
algod,
)
await algorand.send.payment({
amount: algokit.algos(1),
sender: deployer.addr,
receiver: app.appAddress,
})
}

const method = 'hello'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,26 @@ import { {{ contract_name.split('_')|map('capitalize')|join }}Client } from '../
export async function deploy() {
console.log('=== Deploying {{ contract_name.split('_')|map('capitalize')|join }} ===')

const algod = algokit.getAlgoClient()
const indexer = algokit.getAlgoIndexerClient()
const deployer = await algokit.mnemonicAccountFromEnvironment({ name: 'DEPLOYER', fundWith: algokit.algos(3) }, algod)
await algokit.ensureFunded(
{
accountToFund: deployer,
minSpendingBalance: algokit.algos(2),
minFundingIncrement: algokit.algos(2),
},
algod,
)
const appClient = new {{ contract_name.split('_')|map('capitalize')|join }}Client(
{
resolveBy: 'creatorAndName',
findExistingUsing: indexer,
sender: deployer,
creatorAddress: deployer.addr,
},
algod,
)
const algorand = algokit.AlgorandClient.fromEnvironment()
const deployer = await algorand.account.fromEnvironment('DEPLOYER')

const appClient = algorand.client.getTypedAppClientByCreatorAndName({{ contract_name.split('_')|map('capitalize')|join }}Client, {
sender: deployer,
creatorAddress: deployer.addr,
})

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


// If app was just created fund the app account
if (['create', 'replace'].includes(app.operationPerformed)) {
algokit.transferAlgos(
{
amount: algokit.algos(1),
from: deployer,
to: app.appAddress,
},
algod,
)
await algorand.send.payment({
amount: algokit.algos(1),
sender: deployer.addr,
receiver: app.appAddress,
})
}

const method = 'hello'
Expand Down
Loading

0 comments on commit c6ad5fb

Please sign in to comment.