difftreelog
test get rid of AccountId::default
in: master
5 files changed
tests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth633 /**633 /**634 * Get token owner634 * Get token owner635 **/635 **/636 tokenOwner: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<PalletEvmAccountBasicCrossAccountIdRepr>>;636 tokenOwner: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>>;637 /**637 /**638 * Get token owner, in case of nested token - find parent recursive638 * Get token owner, in case of nested token - find parent recursive639 **/639 **/640 topmostTokenOwner: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<PalletEvmAccountBasicCrossAccountIdRepr>>;640 topmostTokenOwner: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>>;641 /**641 /**642 * Get token variable metadata642 * Get token variable metadata643 **/643 **/tests/src/interfaces/unique/definitions.tsdiffbeforeafterboth--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -48,8 +48,8 @@
accountBalance: fun('Get amount of different user tokens', [collectionParam, crossAccountParam()], 'u32'),
balance: fun('Get amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),
allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),
- tokenOwner: fun('Get token owner', [collectionParam, tokenParam], CROSS_ACCOUNT_ID_TYPE),
- topmostTokenOwner: fun('Get token owner, in case of nested token - find parent recursive', [collectionParam, tokenParam], CROSS_ACCOUNT_ID_TYPE),
+ tokenOwner: fun('Get token owner', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),
+ topmostTokenOwner: fun('Get token owner, in case of nested token - find parent recursive', [collectionParam, tokenParam], `Option<${CROSS_ACCOUNT_ID_TYPE}>`),
constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),
variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec<u8>'),
tokenExists: fun('Check if token exists', [collectionParam, tokenParam], 'bool'),
tests/src/nesting/nest.test.tsdiffbeforeafterboth--- a/tests/src/nesting/nest.test.ts
+++ b/tests/src/nesting/nest.test.ts
@@ -4,7 +4,7 @@
import usingApi from '../substrate/substrate-api';
import {createCollectionExpectSuccess, createItemExpectSuccess, getTokenOwner, getTopmostTokenOwner, setCollectionLimitsExpectSuccess, transferExpectSuccess, transferFromExpectSuccess} from '../util/helpers';
-describe.only('nesting', () => {
+describe('nesting', () => {
it('allows to nest/unnest token', async () => {
await usingApi(async api => {
const alice = privateKey('//Alice');
tests/src/rpc.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/rpc.test.ts
@@ -0,0 +1,12 @@
+import {expect} from 'chai';
+import usingApi from './substrate/substrate-api';
+import {createCollectionExpectSuccess, getTokenOwner} from './util/helpers';
+
+describe('getTokenOwner', () => {
+ it('returns None for fungible collection', async () => {
+ await usingApi(async api => {
+ const collection = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+ await expect(getTokenOwner(api, collection, 0)).to.be.rejectedWith(/^owner == null$/);
+ });
+ });
+});
\ No newline at end of file
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -985,14 +985,18 @@
collectionId: number,
token: number,
): Promise<CrossAccountId> {
- return normalizeAccountId((await api.rpc.unique.tokenOwner(collectionId, token)).toJSON() as any);
+ const owner = (await api.rpc.unique.tokenOwner(collectionId, token)).toJSON() as any;
+ if (owner == null) throw new Error('owner == null');
+ return normalizeAccountId(owner);
}
export async function getTopmostTokenOwner(
api: ApiPromise,
collectionId: number,
token: number,
): Promise<CrossAccountId> {
- return normalizeAccountId((await api.rpc.unique.topmostTokenOwner(collectionId, token)).toJSON() as any);
+ const owner = (await api.rpc.unique.topmostTokenOwner(collectionId, token)).toJSON() as any;
+ if (owner == null) throw new Error('owner == null');
+ return normalizeAccountId(owner);
}
export async function isTokenExists(
api: ApiPromise,