Skip to content

Commit fdb9013

Browse files
authored
Merge pull request #8 from tasosbit/chore/check-asset-on-association
chore: check asset on association
2 parents 0af259e + 93bfae1 commit fdb9013

File tree

8 files changed

+1819
-1695
lines changed

8 files changed

+1819
-1695
lines changed

projects/asset_labeling-contracts/smart_contracts/artifacts/asset_labeling/AssetLabeling.approval.puya.map

Lines changed: 1430 additions & 1372 deletions
Large diffs are not rendered by default.

projects/asset_labeling-contracts/smart_contracts/artifacts/asset_labeling/AssetLabeling.approval.teal

Lines changed: 281 additions & 262 deletions
Large diffs are not rendered by default.

projects/asset_labeling-contracts/smart_contracts/artifacts/asset_labeling/AssetLabeling.arc56.json

Lines changed: 59 additions & 59 deletions
Large diffs are not rendered by default.

projects/asset_labeling-contracts/smart_contracts/artifacts/asset_labeling/AssetLabelingClient.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

projects/asset_labeling-contracts/smart_contracts/asset_labeling/contract.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ def get_asset_label_index(self, asset: Asset, label: String) -> UInt64:
251251

252252
@subroutine
253253
def _add_label_to_asset(self, label: String, asset: Asset) -> None:
254+
ensure(not asset_is_deleted(asset.id), S("ERR:NOEXIST"))
254255
ensure(label in self.labels, S("ERR:NOEXIST"))
255256
if asset in self.assets:
256257
# existing operator, check for duplicate

projects/asset_labeling-contracts/tests/asset-labeling.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,4 +699,42 @@ describe('asset labeling contract', () => {
699699

700700
await expect(() => removeLabelFromAsset(operatorClient, assetId, label2)).rejects.toThrow(/ERR:NOEXIST/)
701701
})
702+
703+
test('add label to deleted asset should fail', async () => {
704+
const { testAccount: adminAccount, algorand } = localnet.context
705+
706+
const {assetId} = await algorand.send.assetCreate({
707+
sender: adminAccount.addr,
708+
total: 1000000n, // Total units of the asset
709+
decimals: 0, // Number of decimals for the asset
710+
defaultFrozen: false, // Whether the asset is frozen by default
711+
manager: adminAccount.addr, // Address for the asset manager
712+
reserve: adminAccount.addr, // Address for storing reserve assets
713+
freeze: adminAccount.addr, // Address with freezing capabilities
714+
clawback: adminAccount.addr, // Address with clawback rights
715+
unitName: 'UNIT', // Unit name of the asset
716+
assetName: 'TestAsset', // Asset name
717+
})
718+
await algorand.send.assetDestroy({
719+
sender: adminAccount.addr,
720+
assetId
721+
})
722+
723+
724+
const { adminClient } = await deploy(adminAccount)
725+
const label = 'wo'
726+
const labelName = 'world'
727+
const labelUrl = 'http://'
728+
729+
730+
await addLabel(adminClient, adminAccount, label, labelName, labelUrl)
731+
const operator = await localnet.context.generateAccount({ initialFunds: (0.2).algos() })
732+
await addOperatorToLabel(adminClient, operator, label)
733+
const operatorClient = adminClient.clone({
734+
defaultSender: operator,
735+
defaultSigner: operator.signer,
736+
})
737+
// This should throw
738+
await expect(()=>addLabelToAsset(operatorClient, assetId, label)).rejects.toThrow(/ERR:NOEXIST/)
739+
})
702740
})

projects/asset_labeling-contracts/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
"noEmit": true
2222
},
2323
"include": ["smart_contracts/**/*.ts"],
24-
"exclude": ["node_modules", "dist", "coverage"]
24+
"exclude": ["node_modules", "dist", "coverage"],
25+
"references": [{"path": "./tsconfig.test.json"}]
2526
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"include": ["tests/**/*.ts", "smart_contracts/artifacts/**/*.ts"]
7+
}

0 commit comments

Comments
 (0)