Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert back to previous state delta behaviour #109

Merged
merged 1 commit into from
Feb 2, 2025
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
20 changes: 16 additions & 4 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,14 @@ export function getIndexerTransactionFromAlgodTransaction(t: TransactionInBlock,
key: Buffer.from(key).toString('base64'),
value: new algosdk.indexerModels.EvalDelta({
action: value.action,
bytes: value.bytes ? Buffer.from(value.bytes).toString('base64') : undefined,
uint: value.uint,
...(value.action === 2
? {
uint: value.uint,
}
: {
bytes: value.bytes ? Buffer.from(value.bytes).toString('base64') : undefined,
uint: value.uint,
}),
}),
}),
)
Expand All @@ -489,8 +495,14 @@ export function getIndexerTransactionFromAlgodTransaction(t: TransactionInBlock,
key: Buffer.from(key).toString('base64'),
value: new algosdk.indexerModels.EvalDelta({
action: value.action,
bytes: value.bytes ? Buffer.from(value.bytes).toString('base64') : undefined,
uint: value.uint,
...(value.action === 2
? {
uint: value.uint,
}
: {
bytes: value.bytes ? Buffer.from(value.bytes).toString('base64') : undefined,
uint: value.uint,
}),
}),
}),
),
Expand Down
116 changes: 58 additions & 58 deletions tests/scenarios/transform-complex-txn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,48 +795,46 @@ describe('Complex transaction with many nested inner transactions', () => {
const localStateDelta = transactionForDiff.localStateDelta
const globalStateDelta = transactionForDiff.globalStateDelta
expect(globalStateDelta).toMatchInlineSnapshot(`
[
{
"key": "Y3VycmVudF9taW5lcl9lZmZvcnQ=",
"value": {
"action": 2,
"bytes": "",
"uint": 412000n,
},
},
{
"key": "dG90YWxfZWZmb3J0",
"value": {
"action": 2,
"bytes": "",
"uint": 2129702852933n,
},
},
{
"key": "dG90YWxfdHJhbnNhY3Rpb25z",
"value": {
"action": 2,
"bytes": "",
"uint": 324424783n,
},
},
]`)
[
{
"key": "Y3VycmVudF9taW5lcl9lZmZvcnQ=",
"value": {
"action": 2,
"uint": 412000n,
},
},
{
"key": "dG90YWxfZWZmb3J0",
"value": {
"action": 2,
"uint": 2129702852933n,
},
},
{
"key": "dG90YWxfdHJhbnNhY3Rpb25z",
"value": {
"action": 2,
"uint": 324424783n,
},
},
]
`)
expect(localStateDelta).toMatchInlineSnapshot(`
[
{
"address": "R4Q3KN5RBXUQIJWSVMQUJ7FTL7YURP6DY6W724HTD4Z43IRGUCZ2ORANGE",
"delta": [
{
"key": "ZWZmb3J0",
"value": {
"action": 2,
"bytes": "",
"uint": 412000n,
[
{
"address": "R4Q3KN5RBXUQIJWSVMQUJ7FTL7YURP6DY6W724HTD4Z43IRGUCZ2ORANGE",
"delta": [
{
"key": "ZWZmb3J0",
"value": {
"action": 2,
"uint": 412000n,
},
},
],
},
},
],
},
]`)
]
`)
})

it('Produces base64 encoded programs for an application create transaction', async () => {
Expand All @@ -861,23 +859,25 @@ describe('Complex transaction with many nested inner transactions', () => {

const transaction = getIndexerTransactionFromAlgodTransaction(txn)
const globalStateDelta = transaction.globalStateDelta
expect(globalStateDelta).toMatchInlineSnapshot(`[
EvalDeltaKeyValue {
"key": "cg==",
"value": EvalDelta {
"action": 2,
"bytes": "",
"uint": 6311n,
},
},
EvalDeltaKeyValue {
"key": "cmk=",
"value": EvalDelta {
"action": 1,
"bytes": "gfOn0O9iF4/OGJ6kRsOFfbp/zhAedEwoZL/escO+M+QAAAAAQ/9CAQAAAAACsUi5AwAkCj8UAphDyseTKWeF7KZFZuNK8zA9rbqocWk+NJ5CpMtNsCSq7S8AAAAAAAAAJxAAAABi6BgWCgAAAAAAAAAA",
"uint": 0n,
},
},
]`)
expect(globalStateDelta).toMatchInlineSnapshot(`
[
EvalDeltaKeyValue {
"key": "cg==",
"value": EvalDelta {
"action": 2,
"bytes": undefined,
"uint": 6311n,
},
},
EvalDeltaKeyValue {
"key": "cmk=",
"value": EvalDelta {
"action": 1,
"bytes": "gfOn0O9iF4/OGJ6kRsOFfbp/zhAedEwoZL/escO+M+QAAAAAQ/9CAQAAAAACsUi5AwAkCj8UAphDyseTKWeF7KZFZuNK8zA9rbqocWk+NJ5CpMtNsCSq7S8AAAAAAAAAJxAAAABi6BgWCgAAAAAAAAAA",
"uint": 0n,
},
},
]
`)
})
})