Skip to content

Commit

Permalink
Merge pull request #381 from algorandfoundation/test-algosdk-v3
Browse files Browse the repository at this point in the history
feat: upgrade algosdk + subscriber + utils
  • Loading branch information
PatrickDinh authored Jan 29, 2025
2 parents e4fdeb7 + 3bc055d commit 59052b7
Show file tree
Hide file tree
Showing 175 changed files with 5,669 additions and 4,560 deletions.
368 changes: 139 additions & 229 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
"postinstall": "patch-package"
},
"dependencies": {
"@algorandfoundation/algokit-subscriber": "^2.2.0",
"@algorandfoundation/algokit-utils": "^7.0.0",
"@algorandfoundation/algokit-subscriber": "3.0.1",
"@algorandfoundation/algokit-utils": "^8.1.0",
"@auth0/auth0-react": "^2.2.4",
"@blockshake/defly-connect": "^1.1.6",
"@daffiwallet/connect": "^1.0.3",
"@blockshake/defly-connect": "^1.2.1",
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@hookform/resolvers": "^3.9.0",
"@perawallet/connect": "^1.3.5",
"@perawallet/connect": "^1.4.1",
"@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dialog": "^1.0.5",
Expand All @@ -59,10 +58,10 @@
"@tauri-apps/plugin-process": "^2.2.0",
"@tauri-apps/plugin-shell": "^2.0.1",
"@tauri-apps/plugin-updater": "^2.3.0",
"@txnlab/use-wallet": "^3.11.0",
"@txnlab/use-wallet-react": "^3.11.0",
"@txnlab/use-wallet": "^4.0.0-beta.5",
"@txnlab/use-wallet-react": "^4.0.0-beta.5",
"@xstate/react": "^4.1.1",
"algosdk": "2.10.0",
"algosdk": "3.1.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cmdk": "^1.0.0",
Expand Down Expand Up @@ -100,7 +99,7 @@
"@eslint/js": "^9.15.0",
"@makerx/prettier-config": "^2.0.0",
"@makerx/ts-config": "^1.0.1",
"@makerx/ts-dossier": "^3.0.0",
"@makerx/ts-dossier": "^3.0.1",
"@tauri-apps/cli": "^2.0.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^14.2.2",
Expand Down Expand Up @@ -133,7 +132,7 @@
"typescript-eslint": "^8.15.0",
"vite": "^5.4.14",
"vite-plugin-node-polyfills": "^0.22.0",
"vitest": "^2.1.3"
"vitest": "^2.1.8"
},
"release": {
"branches": [
Expand Down Expand Up @@ -196,7 +195,6 @@
]
},
"overrides": {
"ws@>7.0.0 <7.5.9": "7.5.10",
"path-to-regexp@>= 0.2.0 <8.0.0": "8.0.0"
"ws@>7.0.0 <7.5.9": "7.5.10"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ export function DecodedAbiMethodArguments({ arguments: argumentsProp, multiline
} else if (argument.type === DecodedAbiType.Application) {
return (
<ApplicationLink className="text-primary underline" applicationId={argument.value}>
{argument.value}
{argument.value.toString()}
</ApplicationLink>
)
} else if (argument.type === DecodedAbiType.Asset) {
return (
<AssetIdLink className="text-primary underline" assetId={argument.value}>
{argument.value}
{argument.value.toString()}
</AssetIdLink>
)
} else if (argument.type === DecodedAbiType.Struct) {
Expand Down
93 changes: 81 additions & 12 deletions src/features/abi-methods/data/abi-method.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { AppInterfaceEntity, dbConnectionAtom } from '@/features/common/data/ind
import { upsertAppInterface } from '@/features/app-interfaces/data'
import { getTestStore } from '@/tests/utils/get-test-store'
import { DecodedAbiType } from '@/features/abi-methods/models'
import Arc32TestContractAppSpec from '@/tests/test-app-specs/test-contract.arc32.json'

describe('resolving ABI method', () => {
describe('for an app call with referenced asset', () => {
Expand All @@ -27,7 +28,7 @@ describe('resolving ABI method', () => {
myStore.set(transactionResultsAtom, new Map([[transaction.id, createReadOnlyAtomAndTimestamp(transaction)]]))
myStore.set(assetResultsAtom, new Map([[asset.index, createReadOnlyAtomAndTimestamp(asset)]]))

const applicationId = transaction['application-transaction']!['application-id']!
const applicationId = transaction.applicationTransaction!.applicationId!
const dbConnection = await myStore.get(dbConnectionAtom)
await upsertAppInterface(dbConnection, {
applicationId: applicationId,
Expand All @@ -48,7 +49,7 @@ describe('resolving ABI method', () => {
{
name: 'asset',
type: DecodedAbiType.Asset,
value: 705457144,
value: 705457144n,
length: 9,
multiline: false,
},
Expand All @@ -61,7 +62,7 @@ describe('resolving ABI method', () => {
myStore.set(transactionResultsAtom, new Map([[transaction.id, createReadOnlyAtomAndTimestamp(transaction)]]))
myStore.set(assetResultsAtom, new Map([[asset.index, createReadOnlyAtomAndTimestamp(asset)]]))

const applicationId = transaction['application-transaction']!['application-id']!
const applicationId = transaction.applicationTransaction!.applicationId!
const dbConnection = await myStore.get(dbConnectionAtom)
await upsertAppInterface(dbConnection, {
applicationId: applicationId,
Expand All @@ -82,7 +83,7 @@ describe('resolving ABI method', () => {
{
name: 'asset',
type: DecodedAbiType.Asset,
value: 705457144,
value: 705457144n,
length: 9,
multiline: false,
},
Expand All @@ -97,15 +98,15 @@ describe('resolving ABI method', () => {
const group = groupResultMother
.groupWithTransactions([axferTransaction, appCallTransaction])
.withId('kk6u1A9C9x1roBZOci/4Ne3XtHOtxKRq2O7OLVCbKOc=')
.withRound(appCallTransaction['confirmed-round']!)
.withRound(appCallTransaction.confirmedRound!)
.build()

it('should resolve the correct data with arc32 appspec', async () => {
const myStore = getTestStore()
myStore.set(groupResultsAtom, new Map([[group.id, createReadOnlyAtomAndTimestamp(group)]]))
myStore.set(transactionResultsAtom, new Map([[appCallTransaction.id, createReadOnlyAtomAndTimestamp(appCallTransaction)]]))

const applicationId = appCallTransaction['application-transaction']!['application-id']!
const applicationId = appCallTransaction.applicationTransaction!.applicationId!
const dbConnection = await myStore.get(dbConnectionAtom)
await upsertAppInterface(dbConnection, {
applicationId: applicationId,
Expand Down Expand Up @@ -152,7 +153,7 @@ describe('resolving ABI method', () => {
myStore.set(groupResultsAtom, new Map([[group.id, createReadOnlyAtomAndTimestamp(group)]]))
myStore.set(transactionResultsAtom, new Map([[appCallTransaction.id, createReadOnlyAtomAndTimestamp(appCallTransaction)]]))

const applicationId = appCallTransaction['application-transaction']!['application-id']!
const applicationId = appCallTransaction.applicationTransaction!.applicationId!
const dbConnection = await myStore.get(dbConnectionAtom)
await upsertAppInterface(dbConnection, {
applicationId: applicationId,
Expand Down Expand Up @@ -201,15 +202,15 @@ describe('resolving ABI method', () => {
const group = groupResultMother
.groupWithTransactions([payTransaction, appCallTransaction])
.withId('V5t9TByjm6M6pY9B76O+myDggseVS6bZP1lgizX665w=')
.withRound(appCallTransaction['confirmed-round']!)
.withRound(appCallTransaction.confirmedRound!)
.build()

it('should resolve the correct data', async () => {
const myStore = getTestStore()
myStore.set(groupResultsAtom, new Map([[group.id, createReadOnlyAtomAndTimestamp(group)]]))
myStore.set(transactionResultsAtom, new Map([[appCallTransaction.id, createReadOnlyAtomAndTimestamp(appCallTransaction)]]))

const applicationId = appCallTransaction['application-transaction']!['application-id']!
const applicationId = appCallTransaction.applicationTransaction!.applicationId!
const dbConnection = await myStore.get(dbConnectionAtom)
await upsertAppInterface(dbConnection, {
applicationId: applicationId,
Expand Down Expand Up @@ -349,7 +350,7 @@ describe('resolving ABI method', () => {
{
name: 'asset',
type: DecodedAbiType.Asset,
value: 705457144,
value: 705457144n,
length: 9,
multiline: false,
},
Expand All @@ -363,7 +364,7 @@ describe('resolving ABI method', () => {
{
name: 'application',
type: DecodedAbiType.Application,
value: 705410358,
value: 705410358n,
length: 9,
multiline: false,
},
Expand Down Expand Up @@ -408,7 +409,7 @@ describe('resolving ABI method', () => {
const myStore = getTestStore()
myStore.set(transactionResultsAtom, new Map([[transaction.id, createReadOnlyAtomAndTimestamp(transaction)]]))

const applicationId = transaction['application-transaction']!['application-id']!
const applicationId = transaction.applicationTransaction!.applicationId!
const dbConnection = await myStore.get(dbConnectionAtom)
await upsertAppInterface(dbConnection, {
applicationId: applicationId,
Expand Down Expand Up @@ -512,4 +513,72 @@ describe('resolving ABI method', () => {
expect(abiMethod).toBeUndefined()
})
})

describe('for an inner app call with a reference to another transaction', () => {
const appCallTransaction = transactionResultMother['localnet-64YO3SCTIJQFVTHYFPD74GYCEH5ETU7RVZCGQ5WCXPIEZEWHRE5A']().build()
const group = groupResultMother
.groupWithTransactions([appCallTransaction.innerTxns![0], appCallTransaction.innerTxns![1]])
.withId('8Dp0ZM4bEo4LexOu2AtAhOUBKKttkR2slT8aau9t7+E=')
.withRound(appCallTransaction.confirmedRound!)
.build()

it('should resolve the correct data with arc32 appspec', async () => {
const myStore = getTestStore()
myStore.set(groupResultsAtom, new Map([[group.id, createReadOnlyAtomAndTimestamp(group)]]))
myStore.set(transactionResultsAtom, new Map([[appCallTransaction.id, createReadOnlyAtomAndTimestamp(appCallTransaction)]]))

const applicationId = appCallTransaction.applicationTransaction!.applicationId!
const dbConnection = await myStore.get(dbConnectionAtom)
await upsertAppInterface(dbConnection, {
applicationId: applicationId,
name: 'test',
appSpecVersions: [
{
standard: AppSpecStandard.ARC32,
appSpec: Arc32TestContractAppSpec as unknown as Arc32AppSpec,
},
],
lastModified: createTimestamp(),
} satisfies AppInterfaceEntity)

const innerApplicationId = appCallTransaction.innerTxns![1].applicationTransaction!.applicationId!
await upsertAppInterface(dbConnection, {
applicationId: innerApplicationId,
name: 'test_1',
appSpecVersions: [
{
standard: AppSpecStandard.ARC32,
appSpec: Arc32TestContractAppSpec as unknown as Arc32AppSpec,
},
],
lastModified: createTimestamp(),
} satisfies AppInterfaceEntity)

const abiMethod = await myStore.get(abiMethodResolver(appCallTransaction, getGroupResultAtom))
expect(abiMethod).toBeDefined()
expect(abiMethod!.name).toBe('inner_pay_appl')
expect(abiMethod!.arguments).toStrictEqual([
{
name: 'appId',
type: DecodedAbiType.Uint,
value: 10019n,
length: 5,
multiline: false,
},
])

const innerAbiMethod = await myStore.get(abiMethodResolver(appCallTransaction.innerTxns![1], getGroupResultAtom))
expect(innerAbiMethod).toBeDefined()
expect(innerAbiMethod!.name).toBe('get_pay_txn_amount')
expect(innerAbiMethod!.arguments).toStrictEqual([
{
length: 60,
multiline: false,
name: 'pay_txn',
type: 'Transaction',
value: '64YO3SCTIJQFVTHYFPD74GYCEH5ETU7RVZCGQ5WCXPIEZEWHRE5A/inner/1',
},
])
})
})
})
Loading

0 comments on commit 59052b7

Please sign in to comment.