Skip to content
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
15 changes: 6 additions & 9 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ permissions:
contents: read

jobs:
setup-polytest:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -28,14 +30,9 @@ jobs:
- name: Validate polytest algod_client tests
run: npm run polytest:validate-algod

build-and-test:
needs: setup-polytest
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate transact polytest files
working-directory: packages/transact/
run: npm run polytest:generate

- name: Run CI
uses: ./.github/actions/ci
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ venv/
ENV/

.polytest*/
.algokit*/
polytest_resources/
.algokit*/
13 changes: 9 additions & 4 deletions packages/common/src/codecs/composite/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import type { EncodingFormat } from '../types'
/**
* Map codec - handles Maps with any key type (including Uint8Array, bigint, number)
* Depending on the encoding format, the map is encoded differently:
* - json: Only supports string keys and is represented as an object when encoding.
* An exception is thrown upon encountering a non-string key.
* - json: Supports string and bigint keys. The map is represented as an object when encoding.
* Bigint keys are converted to/from strings (e.g., 1n becomes "1").
* An exception is thrown upon encountering an unsupported key type.
* - msgpack: Preserves key types and is represented as a Map when encoding.
*/
export class MapCodec<K, V, KEncoded = K, VEncoded = V> extends Codec<Map<K, V>, Map<KEncoded, VEncoded> | Record<string, VEncoded>> {
Expand All @@ -28,7 +29,7 @@ export class MapCodec<K, V, KEncoded = K, VEncoded = V> extends Codec<Map<K, V>,
if (format === 'msgpack') {
return true
}
if (this.keyType !== 'string') {
if (this.keyType !== 'string' && this.keyType !== 'bigint') {
throw new Error(`Map key of type '${this.keyType}' is not supported in ${format} format`)
}
}
Expand Down Expand Up @@ -68,7 +69,11 @@ export class MapCodec<K, V, KEncoded = K, VEncoded = V> extends Codec<Map<K, V>,
}

for (const [encodedKey, encodedValue] of entries) {
const key = this.keyCodec.decode(encodedKey as KEncoded, format)
let keyToDecode = encodedKey as KEncoded
if (format === 'json' && this.keyType === 'bigint' && typeof encodedKey === 'string') {
keyToDecode = BigInt(encodedKey) as KEncoded
}
const key = this.keyCodec.decode(keyToDecode, format)
const val = this.valueCodec.decode(encodedValue, format)
result.set(key, val)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/transact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"audit": "better-npm-audit audit",
"format": "prettier --config ../../.prettierrc.cjs --ignore-path ../../.prettierignore --write .",
"pre-commit": "run-s check-types lint:fix audit format test",
"polytest:generate": "polytest --config test_configs/transact.jsonc --git https://github.com/joe-p/algokit-polytest#main generate -t vitest",
"polytest:run": "polytest --config test_configs/transact.jsonc --git https://github.com/joe-p/algokit-polytest#main run --no-parse -t vitest"
"polytest:generate": "polytest --config test_configs/transact.jsonc --git https://github.com/joe-p/algokit-polytest#feat/data_factory generate -t vitest",
"polytest:run": "polytest --config test_configs/transact.jsonc --git https://github.com/joe-p/algokit-polytest#feat/data_factory run --no-parse -t vitest"
},
"dependencies": {},
"peerDependencies": {},
Expand Down
14 changes: 2 additions & 12 deletions packages/transact/tests/app_call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import {
assertDecodeWithPrefix,
assertDecodeWithoutPrefix,
assertEncode,
assertEncodeWithAuthAddress,
assertEncodeWithSignature,
assertEncodedTransactionType,
assertExample,
assertMultisigExample,
assertTransactionId,
} from './transaction_asserts'

Expand All @@ -35,10 +33,6 @@ describe('App Call', () => {
await assertExample(label, testData)
})

test('multisig example', async () => {
await assertMultisigExample(label, testData)
})

test('get transaction id', () => {
assertTransactionId(label, testData)
})
Expand All @@ -59,12 +53,8 @@ describe('App Call', () => {
assertDecodeWithPrefix(label, testData)
})

test('encode with auth address', async () => {
await assertEncodeWithAuthAddress(label, testData)
})

test('encode with signature', () => {
assertEncodeWithSignature(label, testData)
test('encode with signature', async () => {
await assertEncodeWithSignature(label, testData)
})

test('encode', () => {
Expand Down
14 changes: 2 additions & 12 deletions packages/transact/tests/asset_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import {
assertDecodeWithPrefix,
assertDecodeWithoutPrefix,
assertEncode,
assertEncodeWithAuthAddress,
assertEncodeWithSignature,
assertEncodedTransactionType,
assertExample,
assertMultisigExample,
assertTransactionId,
} from './transaction_asserts'
import { Address, ALGORAND_ZERO_ADDRESS_STRING } from '@algorandfoundation/algokit-common'
Expand All @@ -33,10 +31,6 @@ describe('AssetConfig', () => {
await assertExample(label, testData)
})

test('multisig example', async () => {
await assertMultisigExample(label, testData)
})

test('get transaction id', () => {
assertTransactionId(label, testData)
})
Expand All @@ -57,12 +51,8 @@ describe('AssetConfig', () => {
assertDecodeWithPrefix(label, testData)
})

test('encode with auth address', async () => {
await assertEncodeWithAuthAddress(label, testData)
})

test('encode with signature', () => {
assertEncodeWithSignature(label, testData)
test('encode with signature', async () => {
await assertEncodeWithSignature(label, testData)
})

test('encode', () => {
Expand Down
9 changes: 2 additions & 7 deletions packages/transact/tests/asset_freeze.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
assertDecodeWithPrefix,
assertDecodeWithoutPrefix,
assertEncode,
assertEncodeWithAuthAddress,
assertEncodeWithSignature,
assertEncodedTransactionType,
assertExample,
Expand Down Expand Up @@ -51,12 +50,8 @@ describe('Asset Freeze', () => {
assertDecodeWithPrefix(label, testData)
})

test('encode with auth address', async () => {
await assertEncodeWithAuthAddress(label, testData)
})

test('encode with signature', () => {
assertEncodeWithSignature(label, testData)
test('encode with signature', async () => {
await assertEncodeWithSignature(label, testData)
})

test('encode', () => {
Expand Down
14 changes: 2 additions & 12 deletions packages/transact/tests/asset_transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import {
assertDecodeWithPrefix,
assertDecodeWithoutPrefix,
assertEncode,
assertEncodeWithAuthAddress,
assertEncodeWithSignature,
assertEncodedTransactionType,
assertExample,
assertMultisigExample,
assertTransactionId,
} from './transaction_asserts'

Expand All @@ -31,10 +29,6 @@ describe('AssetTransfer', () => {
await assertExample(label, testData)
})

test('multisig example', async () => {
await assertMultisigExample(label, testData)
})

test('get transaction id', () => {
assertTransactionId(label, testData)
})
Expand All @@ -55,12 +49,8 @@ describe('AssetTransfer', () => {
assertDecodeWithPrefix(label, testData)
})

test('encode with auth address', async () => {
await assertEncodeWithAuthAddress(label, testData)
})

test('encode with signature', () => {
assertEncodeWithSignature(label, testData)
test('encode with signature', async () => {
await assertEncodeWithSignature(label, testData)
})

test('encode', () => {
Expand Down
Loading