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

Issue with generated code mutating data types #22

Closed
wants to merge 1 commit into from
Closed
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
63 changes: 62 additions & 1 deletion test/tests/contract-codegen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {assert} from 'chai'

import {ABI, APIClient, Name} from '@wharfkit/antelope'
import {ABI, APIClient, Name, Serializer} from '@wharfkit/antelope'
import {makeClient} from '@wharfkit/mock-data'

import fs from 'fs'
Expand Down Expand Up @@ -81,6 +81,67 @@ suite('codegen', async function () {
}
})

test('bug', async function () {
const data: any = {
requirements: {
team_id: [],
min_power: 0,
min_balance: 0,
min_stake: 0,
min_cumulative_team_contribution: 0,
},
actions: {
delegated_stake: 0,
stake_locked_additional_rounds: 0,
nft_actions: [
{
collection_name: 'dddd',
schema_name: 'dddddd',
template_id: '3',
match_immutable_attributes: [
{
key: 'keyname',
value: 'keytest',
},
],
match_mutable_attributes: [],
burn: false,
lock_rounds: 0,
},
],
balance_payment: 0,
},
rewards: {
nft_mints: [],
balance_deposit: 0,
delegated_stake: 0,
stake_locked_additional_rounds: 0,
activate_powermod_ids: [],
},
limits: {
offer_quantity_remaining: 0,
available_until_round: 0,
},
}

const test = Boid.Types.offeradd.from(data)
/**
* The input for `team_id` was an array and comes back as an empty string
*/
assert.equal(test.requirements.team_id, data.requirements.team_id)
/**
* The value of the `actions.nft_actions[0].match_immutable_attributes[0].value` was a string and comes back as an empty object
*/
assert.equal(
String(test.actions.nft_actions[0].match_immutable_attributes[0].value),
'keytest'
)
/**
* The input for `rewards.activated_powermod_ids` was an array and comes back as an empty string
*/
assert.equal(test.rewards.activate_powermod_ids, data.rewards.activate_powermod_ids)
})

suite('Generated vs Static', function () {
test('Contracts are identical', function () {
for (const source of sources) {
Expand Down
Loading