Skip to content

Commit

Permalink
refactor: 💡 pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sansan committed Nov 22, 2024
1 parent 309a929 commit 7978957
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"es6": true
},
"rules": {
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-useless-constructor": "off",
"no-use-before-define": "off",
"@typescript-eslint/explicit-function-return-type": ["warn"],
Expand Down
3 changes: 2 additions & 1 deletion src/api/procedures/createAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ export async function prepareStorage(
const customTypeData = await prepareStorageForCustomType(
assetType,
values(KnownAssetType),
context
context,
'createAsset'
);

return {
Expand Down
7 changes: 6 additions & 1 deletion src/api/procedures/createNftCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,12 @@ export async function prepareStorage(

const needsLocalMetadata = collectionKeys.some(isLocalMetadata);

const customTypeData = await prepareStorageForCustomType(nftType, values(KnownNftType), context);
const customTypeData = await prepareStorageForCustomType(
nftType,
values(KnownNftType),
context,
'createNftCollection'
);

return {
customTypeData,
Expand Down
5 changes: 2 additions & 3 deletions src/api/procedures/modifyAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ export async function prepareModifyAsset(
rawType = internalAssetTypeToAssetType(newType as KnownAssetType, context);
}

console.log('updating type');

transactions.push(
checkTxType({
transaction: tx.asset.updateAssetType,
Expand Down Expand Up @@ -275,7 +273,8 @@ export async function prepareStorage(
const customTypeData = await prepareStorageForCustomType(
assetType,
values(KnownAssetType),
context
context,
'modifyAsset'
);

return { customTypeData };
Expand Down
1 change: 1 addition & 0 deletions src/api/procedures/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ export interface CreateAssetParams {
* type of security that the Asset represents (e.g. Equity, Debt, Commodity). Common values are included in the
* {@link types!KnownAssetType} enum, but custom values can be used as well. Custom values must be registered on-chain the first time
* they're used, requiring an additional transaction. They aren't tied to a specific Asset
* if using a custom type, it can be provided as a string (representing name) or a BigNumber (representing the custom type ID)
*/
assetType: KnownAssetType | string | BigNumber;
/**
Expand Down
6 changes: 3 additions & 3 deletions src/utils/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,8 @@ export function isV6Spec(specName: string, specVersion: number): boolean {
export async function prepareStorageForCustomType(
customType: string | BigNumber,
knownTypes: string[],
context: Context
context: Context,
method: string
): Promise<Storage['customTypeData']> {
let customTypeData: Storage['customTypeData'];

Expand All @@ -2398,8 +2399,7 @@ export async function prepareStorageForCustomType(
if (rawValue.isEmpty) {
throw new PolymeshError({
code: ErrorCode.DataUnavailable,
message:
'createNftCollection was given a custom type ID that does not have an corresponding value',
message: `${method} was given a custom type ID that does not have an corresponding value`,
data: { customType },
});
}
Expand Down

0 comments on commit 7978957

Please sign in to comment.