Skip to content

Commit

Permalink
chore: regen artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
aorumbayev committed Mar 19, 2024
1 parent ca66b89 commit af71552
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 232 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as algokit from '@algorandfoundation/algokit-utils'
import { TransactionSignerAccount } from '@algorandfoundation/algokit-utils/types/account'
import { AppDetails } from '@algorandfoundation/algokit-utils/types/app-client'
import { useWallet } from '@txnlab/use-wallet'
import { useSnackbar } from 'notistack'
import { useState } from 'react'

import { AppDetails } from '@algorandfoundation/algokit-utils/types/app-client'
import { HelloWorldClient } from '../contracts/hello_world'

import { OnSchemaBreak, OnUpdate } from '@algorandfoundation/algokit-utils/types/app'
import { getAlgodConfigFromViteEnvironment, getIndexerConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'

Expand All @@ -25,7 +23,6 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
port: algodConfig.port,
token: algodConfig.token,
})

const indexerConfig = getIndexerConfigFromViteEnvironment()
const indexer = algokit.getAlgoIndexerClient({
server: indexerConfig.server,
Expand All @@ -39,6 +36,11 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
const sendAppCall = async () => {
setLoading(true)

// Please note, in typical production scenarios,
// you wouldn't want to use deploy directly from your frontend.
// Instead, you would deploy your contract on your backend and reference it by id.
// Given the simplicity of the starter contract, we are deploying it on the frontend
// for demonstration purposes.
const appDetails = {
resolveBy: 'creatorAndName',
sender: { signer, addr: activeAddress } as TransactionSignerAccount,
Expand All @@ -47,12 +49,6 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
} as AppDetails

const appClient = new HelloWorldClient(appDetails, algodClient)

// Please note, in typical production scenarios,
// you wouldn't want to use deploy directly from your frontend.
// Instead, you would deploy your contract on your backend and reference it by id.
// Given the simplicity of the starter contract, we are deploying it on the frontend
// for demonstration purposes.
const isLocal = await algokit.isLocalNet(algodClient)
const deployParams: Parameters<typeof appClient.deploy>[0] = {
allowDelete: isLocal,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as algokit from '@algorandfoundation/algokit-utils'
import { TransactionSignerAccount } from '@algorandfoundation/algokit-utils/types/account'
import { AppDetails } from '@algorandfoundation/algokit-utils/types/app-client'
import { useWallet } from '@txnlab/use-wallet'
import { useSnackbar } from 'notistack'
import { useState } from 'react'

import { AppDetails } from '@algorandfoundation/algokit-utils/types/app-client'
import { HelloWorldClient } from '../contracts/HelloWorld'

import { OnSchemaBreak, OnUpdate } from '@algorandfoundation/algokit-utils/types/app'
import { getAlgodConfigFromViteEnvironment, getIndexerConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'

Expand All @@ -25,7 +23,6 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
port: algodConfig.port,
token: algodConfig.token,
})

const indexerConfig = getIndexerConfigFromViteEnvironment()
const indexer = algokit.getAlgoIndexerClient({
server: indexerConfig.server,
Expand All @@ -39,6 +36,11 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
const sendAppCall = async () => {
setLoading(true)

// Please note, in typical production scenarios,
// you wouldn't want to use deploy directly from your frontend.
// Instead, you would deploy your contract on your backend and reference it by id.
// Given the simplicity of the starter contract, we are deploying it on the frontend
// for demonstration purposes.
const appDetails = {
resolveBy: 'creatorAndName',
sender: { signer, addr: activeAddress } as TransactionSignerAccount,
Expand All @@ -47,12 +49,6 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
} as AppDetails

const appClient = new HelloWorldClient(appDetails, algodClient)

// Please note, in typical production scenarios,
// you wouldn't want to use deploy directly from your frontend.
// Instead, you would deploy your contract on your backend and reference it by id.
// Given the simplicity of the starter contract, we are deploying it on the frontend
// for demonstration purposes.
const deployParams = {
onSchemaBreak: OnSchemaBreak.AppendApp,
onUpdate: OnUpdate.AppendApp,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { describe, test, expect, beforeAll, beforeEach } from '@jest/globals';
import { algorandFixture } from '@algorandfoundation/algokit-utils/testing';
import { ProductionTealscriptReactContractsClient } from '../contracts/clients/ProductionTealscriptReactContractsClient';
import { CalculatorClient } from '../contracts/clients/CalculatorClient';
import * as algokit from '@algorandfoundation/algokit-utils';

const fixture = algorandFixture();
algokit.Config.configure({ populateAppCallResources: true });

let appClient: ProductionTealscriptReactContractsClient;
let appClient: CalculatorClient;

describe('ProductionTealscriptReactContracts', () => {
describe('Calculator', () => {
beforeEach(fixture.beforeEach);

beforeAll(async () => {
await fixture.beforeEach();
const { algod, testAccount } = fixture.context;

appClient = new ProductionTealscriptReactContractsClient(
appClient = new CalculatorClient(
{
sender: testAccount,
resolveBy: 'id',
Expand All @@ -40,4 +40,9 @@ describe('ProductionTealscriptReactContracts', () => {
const diff = await appClient.doMath({ a, b, operation: 'difference' });
expect(diff.return?.valueOf()).toBe(BigInt(a >= b ? a - b : b - a));
});

test('hello', async () => {
const diff = await appClient.hello({ name: 'world!' });
expect(diff.return?.valueOf()).toBe('Hello, world!');
});
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as algokit from '@algorandfoundation/algokit-utils'
import { TransactionSignerAccount } from '@algorandfoundation/algokit-utils/types/account'
import { AppDetails } from '@algorandfoundation/algokit-utils/types/app-client'
import { useWallet } from '@txnlab/use-wallet'
import { useSnackbar } from 'notistack'
import { useState } from 'react'

import { CalculatorClient } from '../contracts/ProductionTealscriptReactContracts'

import { OnSchemaBreak, OnUpdate } from '@algorandfoundation/algokit-utils/types/app'
import { getAlgodConfigFromViteEnvironment, getIndexerConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
import { CalculatorClient } from '../contracts/Calculator'
import { getAlgodConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'

interface AppCallsInterface {
openModal: boolean
Expand All @@ -26,38 +22,26 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
token: algodConfig.token,
})

const indexerConfig = getIndexerConfigFromViteEnvironment()
const indexer = algokit.getAlgoIndexerClient({
server: indexerConfig.server,
port: indexerConfig.port,
token: indexerConfig.token,
})

const { enqueueSnackbar } = useSnackbar()
const { signer, activeAddress } = useWallet()

const sendAppCall = async () => {
setLoading(true)

const appDetails = {
resolveBy: 'creatorAndName',
sender: { signer, addr: activeAddress } as TransactionSignerAccount,
creatorAddress: activeAddress,
findExistingUsing: indexer,
} as AppDetails

const appClient = new CalculatorClient(appDetails, algodClient)

// Please note, in typical production scenarios,
// you wouldn't want to use deploy directly from your frontend.
// Instead, you would deploy your contract on your backend and reference it by id.
// Given the simplicity of the starter contract, we are deploying it on the frontend
// for demonstration purposes.
const deployParams = {
onSchemaBreak: OnSchemaBreak.AppendApp,
onUpdate: OnUpdate.AppendApp,
}
await appClient.deploy(deployParams).catch((e: Error) => {
const appClient = new CalculatorClient(
{
sender: { signer, addr: activeAddress } as TransactionSignerAccount,
resolveBy: 'id',
id: 0,
},
algodClient,
)
await appClient.create.createApplication({}).catch((e: Error) => {
enqueueSnackbar(`Error deploying the contract: ${e.message}`, { variant: 'error' })
setLoading(false)
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as algokit from '@algorandfoundation/algokit-utils'
import { TransactionSignerAccount } from '@algorandfoundation/algokit-utils/types/account'
import { AppDetails } from '@algorandfoundation/algokit-utils/types/app-client'
import { useWallet } from '@txnlab/use-wallet'
import { useSnackbar } from 'notistack'
import { useState } from 'react'

import { AppDetails } from '@algorandfoundation/algokit-utils/types/app-client'
import { HelloWorldClient } from '../contracts/hello_world'

import { OnSchemaBreak, OnUpdate } from '@algorandfoundation/algokit-utils/types/app'
import { getAlgodConfigFromViteEnvironment, getIndexerConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'

Expand All @@ -25,7 +23,6 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
port: algodConfig.port,
token: algodConfig.token,
})

const indexerConfig = getIndexerConfigFromViteEnvironment()
const indexer = algokit.getAlgoIndexerClient({
server: indexerConfig.server,
Expand All @@ -39,6 +36,11 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
const sendAppCall = async () => {
setLoading(true)

// Please note, in typical production scenarios,
// you wouldn't want to use deploy directly from your frontend.
// Instead, you would deploy your contract on your backend and reference it by id.
// Given the simplicity of the starter contract, we are deploying it on the frontend
// for demonstration purposes.
const appDetails = {
resolveBy: 'creatorAndName',
sender: { signer, addr: activeAddress } as TransactionSignerAccount,
Expand All @@ -47,12 +49,6 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
} as AppDetails

const appClient = new HelloWorldClient(appDetails, algodClient)

// Please note, in typical production scenarios,
// you wouldn't want to use deploy directly from your frontend.
// Instead, you would deploy your contract on your backend and reference it by id.
// Given the simplicity of the starter contract, we are deploying it on the frontend
// for demonstration purposes.
const deployParams = {
onSchemaBreak: OnSchemaBreak.AppendApp,
onUpdate: OnUpdate.AppendApp,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as algokit from '@algorandfoundation/algokit-utils'
import { TransactionSignerAccount } from '@algorandfoundation/algokit-utils/types/account'
import { AppDetails } from '@algorandfoundation/algokit-utils/types/app-client'
import { useWallet } from '@txnlab/use-wallet'
import { useSnackbar } from 'notistack'
import { useState } from 'react'

import { AppDetails } from '@algorandfoundation/algokit-utils/types/app-client'
import { HelloWorldClient } from '../contracts/HelloWorld'

import { OnSchemaBreak, OnUpdate } from '@algorandfoundation/algokit-utils/types/app'
import { getAlgodConfigFromViteEnvironment, getIndexerConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'

Expand All @@ -25,7 +23,6 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
port: algodConfig.port,
token: algodConfig.token,
})

const indexerConfig = getIndexerConfigFromViteEnvironment()
const indexer = algokit.getAlgoIndexerClient({
server: indexerConfig.server,
Expand All @@ -39,6 +36,11 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
const sendAppCall = async () => {
setLoading(true)

// Please note, in typical production scenarios,
// you wouldn't want to use deploy directly from your frontend.
// Instead, you would deploy your contract on your backend and reference it by id.
// Given the simplicity of the starter contract, we are deploying it on the frontend
// for demonstration purposes.
const appDetails = {
resolveBy: 'creatorAndName',
sender: { signer, addr: activeAddress } as TransactionSignerAccount,
Expand All @@ -47,12 +49,6 @@ const AppCalls = ({ openModal, setModalState }: AppCallsInterface) => {
} as AppDetails

const appClient = new HelloWorldClient(appDetails, algodClient)

// Please note, in typical production scenarios,
// you wouldn't want to use deploy directly from your frontend.
// Instead, you would deploy your contract on your backend and reference it by id.
// Given the simplicity of the starter contract, we are deploying it on the frontend
// for demonstration purposes.
const deployParams = {
onSchemaBreak: OnSchemaBreak.AppendApp,
onUpdate: OnUpdate.AppendApp,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { describe, test, expect, beforeAll, beforeEach } from '@jest/globals';
import { algorandFixture } from '@algorandfoundation/algokit-utils/testing';
import { StarterTealscriptReactContractsClient } from '../contracts/clients/StarterTealscriptReactContractsClient';
import { CalculatorClient } from '../contracts/clients/CalculatorClient';
import * as algokit from '@algorandfoundation/algokit-utils';

const fixture = algorandFixture();
algokit.Config.configure({ populateAppCallResources: true });

let appClient: StarterTealscriptReactContractsClient;
let appClient: CalculatorClient;

describe('StarterTealscriptReactContracts', () => {
describe('Calculator', () => {
beforeEach(fixture.beforeEach);

beforeAll(async () => {
await fixture.beforeEach();
const { algod, testAccount } = fixture.context;

appClient = new StarterTealscriptReactContractsClient(
appClient = new CalculatorClient(
{
sender: testAccount,
resolveBy: 'id',
Expand All @@ -40,4 +40,9 @@ describe('StarterTealscriptReactContracts', () => {
const diff = await appClient.doMath({ a, b, operation: 'difference' });
expect(diff.return?.valueOf()).toBe(BigInt(a >= b ? a - b : b - a));
});

test('hello', async () => {
const diff = await appClient.hello({ name: 'world!' });
expect(diff.return?.valueOf()).toBe('Hello, world!');
});
});
Loading

0 comments on commit af71552

Please sign in to comment.